element-ps 2.0.20 → 2.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/dist/index.full.js +2 -41
  2. package/dist/index.full.min.js +5 -5
  3. package/dist/index.full.min.js.map +1 -1
  4. package/dist/index.full.min.mjs +5 -5
  5. package/dist/index.full.min.mjs.map +1 -1
  6. package/dist/index.full.mjs +2 -41
  7. package/es/components/affix/index.mjs +2 -2
  8. package/es/components/affix/src/affix.mjs +19 -82
  9. package/es/components/affix/src/affix.mjs.map +1 -1
  10. package/es/components/affix/src/affix2.mjs +82 -19
  11. package/es/components/affix/src/affix2.mjs.map +1 -1
  12. package/es/components/alert/index.mjs +2 -2
  13. package/es/components/alert/src/alert.mjs +33 -83
  14. package/es/components/alert/src/alert.mjs.map +1 -1
  15. package/es/components/alert/src/alert2.mjs +83 -33
  16. package/es/components/alert/src/alert2.mjs.map +1 -1
  17. package/es/components/autocomplete/index.d.ts +5 -5
  18. package/es/components/autocomplete/index.mjs +2 -2
  19. package/es/components/autocomplete/src/autocomplete.mjs +94 -58
  20. package/es/components/autocomplete/src/autocomplete.mjs.map +1 -1
  21. package/es/components/autocomplete/src/autocomplete.vue.d.ts +5 -5
  22. package/es/components/autocomplete/src/autocomplete2.mjs +58 -94
  23. package/es/components/autocomplete/src/autocomplete2.mjs.map +1 -1
  24. package/es/components/avatar/index.mjs +2 -2
  25. package/es/components/avatar/src/avatar.mjs +29 -61
  26. package/es/components/avatar/src/avatar.mjs.map +1 -1
  27. package/es/components/avatar/src/avatar2.mjs +61 -29
  28. package/es/components/avatar/src/avatar2.mjs.map +1 -1
  29. package/es/components/calendar/index.mjs +2 -2
  30. package/es/components/calendar/src/calendar.mjs +9 -188
  31. package/es/components/calendar/src/calendar.mjs.map +1 -1
  32. package/es/components/calendar/src/calendar2.mjs +188 -9
  33. package/es/components/calendar/src/calendar2.mjs.map +1 -1
  34. package/es/components/calendar/src/date-table.mjs +27 -146
  35. package/es/components/calendar/src/date-table.mjs.map +1 -1
  36. package/es/components/calendar/src/date-table2.mjs +146 -27
  37. package/es/components/calendar/src/date-table2.mjs.map +1 -1
  38. package/es/components/carousel/index.mjs +4 -4
  39. package/es/components/carousel/src/carousel-item.mjs +7 -148
  40. package/es/components/carousel/src/carousel-item.mjs.map +1 -1
  41. package/es/components/carousel/src/carousel-item2.mjs +148 -7
  42. package/es/components/carousel/src/carousel-item2.mjs.map +1 -1
  43. package/es/components/carousel/src/carousel.mjs +43 -201
  44. package/es/components/carousel/src/carousel.mjs.map +1 -1
  45. package/es/components/carousel/src/carousel2.mjs +201 -43
  46. package/es/components/carousel/src/carousel2.mjs.map +1 -1
  47. package/es/components/cascader-panel/src/config.mjs +1 -1
  48. package/es/components/cascader-panel/src/index.mjs +1 -1
  49. package/es/components/cascader-panel/src/menu.mjs +1 -1
  50. package/es/components/cascader-panel/src/node.mjs +200 -120
  51. package/es/components/cascader-panel/src/node.mjs.map +1 -1
  52. package/es/components/cascader-panel/src/node2.mjs +120 -200
  53. package/es/components/cascader-panel/src/node2.mjs.map +1 -1
  54. package/es/components/cascader-panel/src/store.mjs +1 -1
  55. package/es/components/collection/src/collection.mjs +1 -34
  56. package/es/components/collection/src/collection.mjs.map +1 -1
  57. package/es/components/divider/index.mjs +2 -2
  58. package/es/components/divider/src/divider.mjs +34 -17
  59. package/es/components/divider/src/divider.mjs.map +1 -1
  60. package/es/components/divider/src/divider2.mjs +17 -34
  61. package/es/components/divider/src/divider2.mjs.map +1 -1
  62. package/es/components/dropdown/index.d.ts +3 -3
  63. package/es/components/dropdown/src/dropdown-item-impl.mjs +3 -12
  64. package/es/components/dropdown/src/dropdown-item-impl.mjs.map +1 -1
  65. package/es/components/dropdown/src/dropdown-item-impl.vue.d.ts +0 -3
  66. package/es/components/dropdown/src/dropdown.d.ts +1 -1
  67. package/es/components/dropdown/src/dropdown.vue.d.ts +3 -3
  68. package/es/components/form/index.mjs +4 -4
  69. package/es/components/form/src/form-item.mjs +177 -46
  70. package/es/components/form/src/form-item.mjs.map +1 -1
  71. package/es/components/form/src/form-item2.mjs +46 -177
  72. package/es/components/form/src/form-item2.mjs.map +1 -1
  73. package/es/components/form/src/form.mjs +40 -45
  74. package/es/components/form/src/form.mjs.map +1 -1
  75. package/es/components/form/src/form2.mjs +45 -40
  76. package/es/components/form/src/form2.mjs.map +1 -1
  77. package/es/components/image/index.mjs +2 -2
  78. package/es/components/image/src/image.mjs +170 -46
  79. package/es/components/image/src/image.mjs.map +1 -1
  80. package/es/components/image/src/image2.mjs +46 -170
  81. package/es/components/image/src/image2.mjs.map +1 -1
  82. package/es/components/image-viewer/index.mjs +2 -2
  83. package/es/components/image-viewer/src/image-viewer.mjs +31 -210
  84. package/es/components/image-viewer/src/image-viewer.mjs.map +1 -1
  85. package/es/components/image-viewer/src/image-viewer2.mjs +210 -31
  86. package/es/components/image-viewer/src/image-viewer2.mjs.map +1 -1
  87. package/es/components/index.mjs +23 -23
  88. package/es/components/input-number/index.mjs +2 -2
  89. package/es/components/input-number/src/input-number.mjs +46 -171
  90. package/es/components/input-number/src/input-number.mjs.map +1 -1
  91. package/es/components/input-number/src/input-number2.mjs +171 -46
  92. package/es/components/input-number/src/input-number2.mjs.map +1 -1
  93. package/es/components/menu/index.d.ts +3 -3
  94. package/es/components/menu/src/menu.d.ts +4 -4
  95. package/es/components/popover/index.d.ts +6 -6
  96. package/es/components/popover/src/index.vue.d.ts +3 -3
  97. package/es/components/popover/src/popover.d.ts +1 -1
  98. package/es/components/popper/index.mjs +2 -2
  99. package/es/components/popper/src/arrow.mjs +7 -31
  100. package/es/components/popper/src/arrow.mjs.map +1 -1
  101. package/es/components/popper/src/arrow2.mjs +31 -7
  102. package/es/components/popper/src/arrow2.mjs.map +1 -1
  103. package/es/components/radio/index.mjs +2 -2
  104. package/es/components/radio/src/radio-button.mjs +1 -1
  105. package/es/components/radio/src/radio-button2.mjs +1 -1
  106. package/es/components/radio/src/radio.mjs +62 -74
  107. package/es/components/radio/src/radio.mjs.map +1 -1
  108. package/es/components/radio/src/radio2.mjs +74 -62
  109. package/es/components/radio/src/radio2.mjs.map +1 -1
  110. package/es/components/rate/index.mjs +2 -2
  111. package/es/components/rate/src/rate.mjs +84 -169
  112. package/es/components/rate/src/rate.mjs.map +1 -1
  113. package/es/components/rate/src/rate2.mjs +169 -84
  114. package/es/components/rate/src/rate2.mjs.map +1 -1
  115. package/es/components/result/index.mjs +2 -2
  116. package/es/components/result/src/result.mjs +28 -73
  117. package/es/components/result/src/result.mjs.map +1 -1
  118. package/es/components/result/src/result2.mjs +73 -28
  119. package/es/components/result/src/result2.mjs.map +1 -1
  120. package/es/components/select/index.d.ts +5 -5
  121. package/es/components/select/src/select.vue.d.ts +5 -5
  122. package/es/components/select/src/useSelect.d.ts +5 -5
  123. package/es/components/select-v2/index.d.ts +10 -10
  124. package/es/components/select-v2/src/option-item.vue.d.ts +1 -1
  125. package/es/components/select-v2/src/select.vue.d.ts +5 -5
  126. package/es/components/select-v2/src/useSelect.d.ts +5 -5
  127. package/es/components/skeleton/index.mjs +4 -4
  128. package/es/components/skeleton/src/skeleton-item.mjs +18 -23
  129. package/es/components/skeleton/src/skeleton-item.mjs.map +1 -1
  130. package/es/components/skeleton/src/skeleton-item2.mjs +23 -18
  131. package/es/components/skeleton/src/skeleton-item2.mjs.map +1 -1
  132. package/es/components/skeleton/src/skeleton.mjs +22 -49
  133. package/es/components/skeleton/src/skeleton.mjs.map +1 -1
  134. package/es/components/skeleton/src/skeleton2.mjs +49 -22
  135. package/es/components/skeleton/src/skeleton2.mjs.map +1 -1
  136. package/es/components/table/index.d.ts +1 -1
  137. package/es/components/table/src/filter-panel.vue.d.ts +5 -5
  138. package/es/components/table/src/table.vue.d.ts +1 -1
  139. package/es/components/tabs/index.mjs +3 -3
  140. package/es/components/tabs/src/tab-bar.mjs +76 -7
  141. package/es/components/tabs/src/tab-bar.mjs.map +1 -1
  142. package/es/components/tabs/src/tab-bar2.mjs +7 -76
  143. package/es/components/tabs/src/tab-bar2.mjs.map +1 -1
  144. package/es/components/tabs/src/tab-nav.mjs +1 -1
  145. package/es/components/tabs/src/tab-pane.mjs +14 -60
  146. package/es/components/tabs/src/tab-pane.mjs.map +1 -1
  147. package/es/components/tabs/src/tab-pane2.mjs +60 -14
  148. package/es/components/tabs/src/tab-pane2.mjs.map +1 -1
  149. package/es/components/time-picker/src/common/picker.vue.d.ts +5 -5
  150. package/es/components/tooltip/index.d.ts +3 -3
  151. package/es/components/tooltip/src/tooltip.d.ts +1 -1
  152. package/es/components/tooltip/src/tooltip.mjs +1 -1
  153. package/es/components/tooltip/src/tooltip.vue.d.ts +3 -3
  154. package/es/components/tooltip/src/trigger.vue.d.ts +3 -3
  155. package/es/components/tooltip-v2/index.mjs +2 -2
  156. package/es/components/tooltip-v2/src/arrow.mjs +22 -38
  157. package/es/components/tooltip-v2/src/arrow.mjs.map +1 -1
  158. package/es/components/tooltip-v2/src/arrow2.mjs +38 -22
  159. package/es/components/tooltip-v2/src/arrow2.mjs.map +1 -1
  160. package/es/components/tooltip-v2/src/tooltip.mjs +2 -2
  161. package/es/components/tooltip-v2/src/tooltip2.mjs +4 -4
  162. package/es/components/tooltip-v2/src/trigger.mjs +89 -11
  163. package/es/components/tooltip-v2/src/trigger.mjs.map +1 -1
  164. package/es/components/tooltip-v2/src/trigger2.mjs +11 -89
  165. package/es/components/tooltip-v2/src/trigger2.mjs.map +1 -1
  166. package/es/components/upload/index.mjs +1 -1
  167. package/es/components/upload/src/upload-content.mjs +1 -1
  168. package/es/components/upload/src/upload-dragger.mjs +32 -11
  169. package/es/components/upload/src/upload-dragger.mjs.map +1 -1
  170. package/es/components/upload/src/upload-dragger2.mjs +11 -32
  171. package/es/components/upload/src/upload-dragger2.mjs.map +1 -1
  172. package/es/index.mjs +23 -23
  173. package/lib/components/affix/index.js +2 -2
  174. package/lib/components/affix/src/affix.js +19 -82
  175. package/lib/components/affix/src/affix.js.map +1 -1
  176. package/lib/components/affix/src/affix2.js +82 -19
  177. package/lib/components/affix/src/affix2.js.map +1 -1
  178. package/lib/components/alert/index.js +2 -2
  179. package/lib/components/alert/src/alert.js +33 -82
  180. package/lib/components/alert/src/alert.js.map +1 -1
  181. package/lib/components/alert/src/alert2.js +82 -33
  182. package/lib/components/alert/src/alert2.js.map +1 -1
  183. package/lib/components/autocomplete/index.d.ts +5 -5
  184. package/lib/components/autocomplete/index.js +2 -2
  185. package/lib/components/autocomplete/src/autocomplete.js +94 -58
  186. package/lib/components/autocomplete/src/autocomplete.js.map +1 -1
  187. package/lib/components/autocomplete/src/autocomplete.vue.d.ts +5 -5
  188. package/lib/components/autocomplete/src/autocomplete2.js +58 -94
  189. package/lib/components/autocomplete/src/autocomplete2.js.map +1 -1
  190. package/lib/components/avatar/index.js +2 -2
  191. package/lib/components/avatar/src/avatar.js +29 -61
  192. package/lib/components/avatar/src/avatar.js.map +1 -1
  193. package/lib/components/avatar/src/avatar2.js +61 -29
  194. package/lib/components/avatar/src/avatar2.js.map +1 -1
  195. package/lib/components/calendar/index.js +2 -2
  196. package/lib/components/calendar/src/calendar.js +9 -192
  197. package/lib/components/calendar/src/calendar.js.map +1 -1
  198. package/lib/components/calendar/src/calendar2.js +192 -9
  199. package/lib/components/calendar/src/calendar2.js.map +1 -1
  200. package/lib/components/calendar/src/date-table.js +30 -151
  201. package/lib/components/calendar/src/date-table.js.map +1 -1
  202. package/lib/components/calendar/src/date-table2.js +151 -30
  203. package/lib/components/calendar/src/date-table2.js.map +1 -1
  204. package/lib/components/carousel/index.js +4 -4
  205. package/lib/components/carousel/src/carousel-item.js +7 -148
  206. package/lib/components/carousel/src/carousel-item.js.map +1 -1
  207. package/lib/components/carousel/src/carousel-item2.js +148 -7
  208. package/lib/components/carousel/src/carousel-item2.js.map +1 -1
  209. package/lib/components/carousel/src/carousel.js +43 -201
  210. package/lib/components/carousel/src/carousel.js.map +1 -1
  211. package/lib/components/carousel/src/carousel2.js +201 -43
  212. package/lib/components/carousel/src/carousel2.js.map +1 -1
  213. package/lib/components/cascader-panel/src/config.js +1 -1
  214. package/lib/components/cascader-panel/src/index.js +1 -1
  215. package/lib/components/cascader-panel/src/menu.js +1 -1
  216. package/lib/components/cascader-panel/src/node.js +200 -121
  217. package/lib/components/cascader-panel/src/node.js.map +1 -1
  218. package/lib/components/cascader-panel/src/node2.js +121 -200
  219. package/lib/components/cascader-panel/src/node2.js.map +1 -1
  220. package/lib/components/cascader-panel/src/store.js +1 -1
  221. package/lib/components/collection/src/collection.js +0 -33
  222. package/lib/components/collection/src/collection.js.map +1 -1
  223. package/lib/components/divider/index.js +2 -2
  224. package/lib/components/divider/src/divider.js +34 -17
  225. package/lib/components/divider/src/divider.js.map +1 -1
  226. package/lib/components/divider/src/divider2.js +17 -34
  227. package/lib/components/divider/src/divider2.js.map +1 -1
  228. package/lib/components/dropdown/index.d.ts +3 -3
  229. package/lib/components/dropdown/src/dropdown-item-impl.js +1 -10
  230. package/lib/components/dropdown/src/dropdown-item-impl.js.map +1 -1
  231. package/lib/components/dropdown/src/dropdown-item-impl.vue.d.ts +0 -3
  232. package/lib/components/dropdown/src/dropdown.d.ts +1 -1
  233. package/lib/components/dropdown/src/dropdown.vue.d.ts +3 -3
  234. package/lib/components/form/index.js +4 -4
  235. package/lib/components/form/src/form-item.js +177 -47
  236. package/lib/components/form/src/form-item.js.map +1 -1
  237. package/lib/components/form/src/form-item2.js +47 -177
  238. package/lib/components/form/src/form-item2.js.map +1 -1
  239. package/lib/components/form/src/form.js +40 -45
  240. package/lib/components/form/src/form.js.map +1 -1
  241. package/lib/components/form/src/form2.js +45 -40
  242. package/lib/components/form/src/form2.js.map +1 -1
  243. package/lib/components/image/index.js +2 -2
  244. package/lib/components/image/src/image.js +170 -46
  245. package/lib/components/image/src/image.js.map +1 -1
  246. package/lib/components/image/src/image2.js +46 -170
  247. package/lib/components/image/src/image2.js.map +1 -1
  248. package/lib/components/image-viewer/index.js +2 -2
  249. package/lib/components/image-viewer/src/image-viewer.js +31 -210
  250. package/lib/components/image-viewer/src/image-viewer.js.map +1 -1
  251. package/lib/components/image-viewer/src/image-viewer2.js +210 -31
  252. package/lib/components/image-viewer/src/image-viewer2.js.map +1 -1
  253. package/lib/components/index.js +23 -23
  254. package/lib/components/input-number/index.js +2 -2
  255. package/lib/components/input-number/src/input-number.js +46 -171
  256. package/lib/components/input-number/src/input-number.js.map +1 -1
  257. package/lib/components/input-number/src/input-number2.js +171 -46
  258. package/lib/components/input-number/src/input-number2.js.map +1 -1
  259. package/lib/components/menu/index.d.ts +3 -3
  260. package/lib/components/menu/src/menu.d.ts +4 -4
  261. package/lib/components/popover/index.d.ts +6 -6
  262. package/lib/components/popover/src/index.vue.d.ts +3 -3
  263. package/lib/components/popover/src/popover.d.ts +1 -1
  264. package/lib/components/popper/index.js +2 -2
  265. package/lib/components/popper/src/arrow.js +7 -31
  266. package/lib/components/popper/src/arrow.js.map +1 -1
  267. package/lib/components/popper/src/arrow2.js +31 -7
  268. package/lib/components/popper/src/arrow2.js.map +1 -1
  269. package/lib/components/radio/index.js +2 -2
  270. package/lib/components/radio/src/radio-button.js +1 -1
  271. package/lib/components/radio/src/radio-button2.js +1 -1
  272. package/lib/components/radio/src/radio.js +64 -73
  273. package/lib/components/radio/src/radio.js.map +1 -1
  274. package/lib/components/radio/src/radio2.js +73 -64
  275. package/lib/components/radio/src/radio2.js.map +1 -1
  276. package/lib/components/rate/index.js +2 -2
  277. package/lib/components/rate/src/rate.js +84 -169
  278. package/lib/components/rate/src/rate.js.map +1 -1
  279. package/lib/components/rate/src/rate2.js +169 -84
  280. package/lib/components/rate/src/rate2.js.map +1 -1
  281. package/lib/components/result/index.js +2 -2
  282. package/lib/components/result/src/result.js +30 -73
  283. package/lib/components/result/src/result.js.map +1 -1
  284. package/lib/components/result/src/result2.js +73 -30
  285. package/lib/components/result/src/result2.js.map +1 -1
  286. package/lib/components/select/index.d.ts +5 -5
  287. package/lib/components/select/src/select.vue.d.ts +5 -5
  288. package/lib/components/select/src/useSelect.d.ts +5 -5
  289. package/lib/components/select-v2/index.d.ts +10 -10
  290. package/lib/components/select-v2/src/option-item.vue.d.ts +1 -1
  291. package/lib/components/select-v2/src/select.vue.d.ts +5 -5
  292. package/lib/components/select-v2/src/useSelect.d.ts +5 -5
  293. package/lib/components/skeleton/index.js +4 -4
  294. package/lib/components/skeleton/src/skeleton-item.js +18 -23
  295. package/lib/components/skeleton/src/skeleton-item.js.map +1 -1
  296. package/lib/components/skeleton/src/skeleton-item2.js +23 -18
  297. package/lib/components/skeleton/src/skeleton-item2.js.map +1 -1
  298. package/lib/components/skeleton/src/skeleton.js +22 -49
  299. package/lib/components/skeleton/src/skeleton.js.map +1 -1
  300. package/lib/components/skeleton/src/skeleton2.js +49 -22
  301. package/lib/components/skeleton/src/skeleton2.js.map +1 -1
  302. package/lib/components/table/index.d.ts +1 -1
  303. package/lib/components/table/src/filter-panel.vue.d.ts +5 -5
  304. package/lib/components/table/src/table.vue.d.ts +1 -1
  305. package/lib/components/tabs/index.js +3 -3
  306. package/lib/components/tabs/src/tab-bar.js +76 -7
  307. package/lib/components/tabs/src/tab-bar.js.map +1 -1
  308. package/lib/components/tabs/src/tab-bar2.js +7 -76
  309. package/lib/components/tabs/src/tab-bar2.js.map +1 -1
  310. package/lib/components/tabs/src/tab-nav.js +1 -1
  311. package/lib/components/tabs/src/tab-pane.js +14 -60
  312. package/lib/components/tabs/src/tab-pane.js.map +1 -1
  313. package/lib/components/tabs/src/tab-pane2.js +60 -14
  314. package/lib/components/tabs/src/tab-pane2.js.map +1 -1
  315. package/lib/components/time-picker/src/common/picker.vue.d.ts +5 -5
  316. package/lib/components/tooltip/index.d.ts +3 -3
  317. package/lib/components/tooltip/src/tooltip.d.ts +1 -1
  318. package/lib/components/tooltip/src/tooltip.js +1 -1
  319. package/lib/components/tooltip/src/tooltip.vue.d.ts +3 -3
  320. package/lib/components/tooltip/src/trigger.vue.d.ts +3 -3
  321. package/lib/components/tooltip-v2/index.js +2 -2
  322. package/lib/components/tooltip-v2/src/arrow.js +23 -38
  323. package/lib/components/tooltip-v2/src/arrow.js.map +1 -1
  324. package/lib/components/tooltip-v2/src/arrow2.js +38 -23
  325. package/lib/components/tooltip-v2/src/arrow2.js.map +1 -1
  326. package/lib/components/tooltip-v2/src/tooltip.js +2 -2
  327. package/lib/components/tooltip-v2/src/tooltip2.js +4 -4
  328. package/lib/components/tooltip-v2/src/trigger.js +89 -11
  329. package/lib/components/tooltip-v2/src/trigger.js.map +1 -1
  330. package/lib/components/tooltip-v2/src/trigger2.js +11 -89
  331. package/lib/components/tooltip-v2/src/trigger2.js.map +1 -1
  332. package/lib/components/upload/index.js +1 -1
  333. package/lib/components/upload/src/upload-content.js +1 -1
  334. package/lib/components/upload/src/upload-dragger.js +32 -12
  335. package/lib/components/upload/src/upload-dragger.js.map +1 -1
  336. package/lib/components/upload/src/upload-dragger2.js +12 -32
  337. package/lib/components/upload/src/upload-dragger2.js.map +1 -1
  338. package/lib/index.js +23 -23
  339. package/package.json +1 -1
  340. package/web-types.json +1 -1
@@ -2,157 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var vue = require('vue');
6
5
  require('../../../utils/index.js');
7
- require('../../../hooks/index.js');
8
- require('../../../tokens/index.js');
9
- var carouselItem = require('./carousel-item2.js');
10
- var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
11
- var index = require('../../../hooks/use-namespace/index.js');
12
- var carousel = require('../../../tokens/carousel.js');
13
- var error = require('../../../utils/error.js');
14
- var types = require('../../../utils/types.js');
6
+ var props = require('../../../utils/vue/props.js');
15
7
 
16
- const __default__ = {
17
- name: "PsCarouselItem"
18
- };
19
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
20
- ...__default__,
21
- props: carouselItem.carouselItemProps,
22
- setup(__props) {
23
- const props = __props;
24
- const ns = index.useNamespace("carousel");
25
- const COMPONENT_NAME = "PsCarouselItem";
26
- const carouselContext = vue.inject(carousel.carouselContextKey);
27
- const instance = vue.getCurrentInstance();
28
- if (!carouselContext) {
29
- error.debugWarn(COMPONENT_NAME, "usage: <ps-carousel></ps-carousel-item></ps-carousel>");
30
- }
31
- if (!instance) {
32
- error.debugWarn(COMPONENT_NAME, "compositional hook can only be invoked inside setups");
33
- }
34
- const CARD_SCALE = 0.83;
35
- const hover = vue.ref(false);
36
- const translate = vue.ref(0);
37
- const scale = vue.ref(1);
38
- const active = vue.ref(false);
39
- const ready = vue.ref(false);
40
- const inStage = vue.ref(false);
41
- const animating = vue.ref(false);
42
- const { isCardType, isVertical } = carouselContext;
43
- const itemStyle = vue.computed(() => {
44
- const translateType = `translate${vue.unref(isVertical) ? "Y" : "X"}`;
45
- const _translate = `${translateType}(${vue.unref(translate)}px)`;
46
- const _scale = `scale(${vue.unref(scale)})`;
47
- const transform = [_translate, _scale].join(" ");
48
- return {
49
- transform
50
- };
51
- });
52
- function processIndex(index, activeIndex, length) {
53
- const lastItemIndex = length - 1;
54
- const prevItemIndex = activeIndex - 1;
55
- const nextItemIndex = activeIndex + 1;
56
- const halfItemIndex = length / 2;
57
- if (activeIndex === 0 && index === lastItemIndex) {
58
- return -1;
59
- } else if (activeIndex === lastItemIndex && index === 0) {
60
- return length;
61
- } else if (index < prevItemIndex && activeIndex - index >= halfItemIndex) {
62
- return length + 1;
63
- } else if (index > nextItemIndex && index - activeIndex >= halfItemIndex) {
64
- return -2;
65
- }
66
- return index;
67
- }
68
- function calcCardTranslate(index, activeIndex) {
69
- var _a;
70
- const parentWidth = ((_a = carouselContext.root.value) == null ? void 0 : _a.offsetWidth) || 0;
71
- if (inStage.value) {
72
- return parentWidth * ((2 - CARD_SCALE) * (index - activeIndex) + 1) / 4;
73
- } else if (index < activeIndex) {
74
- return -(1 + CARD_SCALE) * parentWidth / 4;
75
- } else {
76
- return (3 + CARD_SCALE) * parentWidth / 4;
77
- }
78
- }
79
- function calcTranslate(index, activeIndex, isVertical2) {
80
- const rootEl = carouselContext.root.value;
81
- if (!rootEl)
82
- return 0;
83
- const distance = (isVertical2 ? rootEl.offsetHeight : rootEl.offsetWidth) || 0;
84
- return distance * (index - activeIndex);
85
- }
86
- const translateItem = (index, activeIndex, oldIndex) => {
87
- var _a;
88
- const _isCardType = vue.unref(isCardType);
89
- const carouselItemLength = (_a = carouselContext.items.value.length) != null ? _a : Number.NaN;
90
- const isActive = index === activeIndex;
91
- if (!_isCardType && !types.isUndefined(oldIndex)) {
92
- animating.value = isActive || index === oldIndex;
93
- }
94
- if (!isActive && carouselItemLength > 2 && carouselContext.loop) {
95
- index = processIndex(index, activeIndex, carouselItemLength);
96
- }
97
- const _isVertical = vue.unref(isVertical);
98
- active.value = isActive;
99
- if (_isCardType) {
100
- if (_isVertical) {
101
- error.debugWarn("Carousel", "vertical direction is not supported for card mode");
102
- }
103
- inStage.value = Math.round(Math.abs(index - activeIndex)) <= 1;
104
- translate.value = calcCardTranslate(index, activeIndex);
105
- scale.value = vue.unref(active) ? 1 : CARD_SCALE;
106
- } else {
107
- translate.value = calcTranslate(index, activeIndex, _isVertical);
108
- }
109
- ready.value = true;
110
- };
111
- vue.onMounted(() => {
112
- carouselContext.addItem({
113
- props,
114
- states: vue.reactive({
115
- hover,
116
- translate,
117
- scale,
118
- active,
119
- ready,
120
- inStage,
121
- animating
122
- }),
123
- uid: instance.uid,
124
- translateItem
125
- });
126
- });
127
- vue.onUnmounted(() => {
128
- carouselContext.removeItem(instance.uid);
129
- });
130
- return (_ctx, _cache) => {
131
- return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
132
- class: vue.normalizeClass([
133
- vue.unref(ns).e("item"),
134
- vue.unref(ns).is("active", active.value),
135
- vue.unref(ns).is("in-stage", inStage.value),
136
- vue.unref(ns).is("hover", hover.value),
137
- vue.unref(ns).is("animating", animating.value),
138
- { [vue.unref(ns).em("item", "card")]: vue.unref(isCardType) }
139
- ]),
140
- style: vue.normalizeStyle(vue.unref(itemStyle))
141
- }, [
142
- vue.unref(isCardType) ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
143
- key: 0,
144
- class: vue.normalizeClass(vue.unref(ns).e("mask"))
145
- }, null, 2)), [
146
- [vue.vShow, !active.value]
147
- ]) : vue.createCommentVNode("v-if", true),
148
- vue.renderSlot(_ctx.$slots, "default")
149
- ], 6)), [
150
- [vue.vShow, ready.value]
151
- ]);
152
- };
8
+ const carouselItemProps = props.buildProps({
9
+ name: { type: String, default: "" },
10
+ label: {
11
+ type: [String, Number],
12
+ default: ""
153
13
  }
154
14
  });
155
- var CarouselItem = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/carousel/src/carousel-item.vue"]]);
156
15
 
157
- exports["default"] = CarouselItem;
16
+ exports.carouselItemProps = carouselItemProps;
158
17
  //# sourceMappingURL=carousel-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"carousel-item.js","sources":["../../../../../../packages/components/carousel/src/carousel-item.vue"],"sourcesContent":["<template>\n <div\n v-show=\"ready\"\n :class=\"[\n ns.e('item'),\n ns.is('active', active),\n ns.is('in-stage', inStage),\n ns.is('hover', hover),\n ns.is('animating', animating),\n { [ns.em('item', 'card')]: isCardType },\n ]\"\n :style=\"itemStyle\"\n >\n <div v-if=\"isCardType\" v-show=\"!active\" :class=\"ns.e('mask')\" />\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport {\n computed,\n getCurrentInstance,\n inject,\n onMounted,\n onUnmounted,\n reactive,\n ref,\n unref,\n} from 'vue'\nimport { debugWarn, isUndefined } from '@element-ps/utils'\nimport { useNamespace } from '@element-ps/hooks'\nimport { carouselContextKey } from '@element-ps/tokens'\nimport { carouselItemProps } from './carousel-item'\n\nimport type { CSSProperties } from 'vue'\n\ndefineOptions({\n name: 'PsCarouselItem',\n})\n\nconst props = defineProps(carouselItemProps)\nconst ns = useNamespace('carousel')\nconst COMPONENT_NAME = 'PsCarouselItem'\n// inject\nconst carouselContext = inject(carouselContextKey)!\n// instance\nconst instance = getCurrentInstance()!\nif (!carouselContext) {\n debugWarn(\n COMPONENT_NAME,\n 'usage: <ps-carousel></ps-carousel-item></ps-carousel>'\n )\n}\n\nif (!instance) {\n debugWarn(\n COMPONENT_NAME,\n 'compositional hook can only be invoked inside setups'\n )\n}\n\nconst CARD_SCALE = 0.83\n\nconst hover = ref(false)\nconst translate = ref(0)\nconst scale = ref(1)\nconst active = ref(false)\nconst ready = ref(false)\nconst inStage = ref(false)\nconst animating = ref(false)\n\n// computed\nconst { isCardType, isVertical } = carouselContext\n\nconst itemStyle = computed<CSSProperties>(() => {\n const translateType = `translate${unref(isVertical) ? 'Y' : 'X'}`\n const _translate = `${translateType}(${unref(translate)}px)`\n const _scale = `scale(${unref(scale)})`\n const transform = [_translate, _scale].join(' ')\n\n return {\n transform,\n }\n})\n\n// methods\n\nfunction processIndex(index: number, activeIndex: number, length: number) {\n const lastItemIndex = length - 1\n const prevItemIndex = activeIndex - 1\n const nextItemIndex = activeIndex + 1\n const halfItemIndex = length / 2\n\n if (activeIndex === 0 && index === lastItemIndex) {\n return -1\n } else if (activeIndex === lastItemIndex && index === 0) {\n return length\n } else if (index < prevItemIndex && activeIndex - index >= halfItemIndex) {\n return length + 1\n } else if (index > nextItemIndex && index - activeIndex >= halfItemIndex) {\n return -2\n }\n return index\n}\n\nfunction calcCardTranslate(index: number, activeIndex: number) {\n const parentWidth = carouselContext.root.value?.offsetWidth || 0\n if (inStage.value) {\n return (parentWidth * ((2 - CARD_SCALE) * (index - activeIndex) + 1)) / 4\n } else if (index < activeIndex) {\n return (-(1 + CARD_SCALE) * parentWidth) / 4\n } else {\n return ((3 + CARD_SCALE) * parentWidth) / 4\n }\n}\n\nfunction calcTranslate(\n index: number,\n activeIndex: number,\n isVertical: boolean\n) {\n const rootEl = carouselContext.root.value\n if (!rootEl) return 0\n\n const distance = (isVertical ? rootEl.offsetHeight : rootEl.offsetWidth) || 0\n return distance * (index - activeIndex)\n}\n\nconst translateItem = (\n index: number,\n activeIndex: number,\n oldIndex?: number\n) => {\n const _isCardType = unref(isCardType)\n const carouselItemLength = carouselContext.items.value.length ?? Number.NaN\n\n const isActive = index === activeIndex\n if (!_isCardType && !isUndefined(oldIndex)) {\n animating.value = isActive || index === oldIndex\n }\n\n if (!isActive && carouselItemLength > 2 && carouselContext.loop) {\n index = processIndex(index, activeIndex, carouselItemLength)\n }\n\n const _isVertical = unref(isVertical)\n active.value = isActive\n\n if (_isCardType) {\n if (_isVertical) {\n debugWarn('Carousel', 'vertical direction is not supported for card mode')\n }\n inStage.value = Math.round(Math.abs(index - activeIndex)) <= 1\n translate.value = calcCardTranslate(index, activeIndex)\n scale.value = unref(active) ? 1 : CARD_SCALE\n } else {\n translate.value = calcTranslate(index, activeIndex, _isVertical)\n }\n\n ready.value = true\n}\n\n// lifecycle\nonMounted(() => {\n carouselContext.addItem({\n props,\n states: reactive({\n hover,\n translate,\n scale,\n active,\n ready,\n inStage,\n animating,\n }),\n uid: instance.uid,\n translateItem,\n })\n})\n\nonUnmounted(() => {\n carouselContext.removeItem(instance.uid)\n})\n</script>\n"],"names":["useNamespace","inject","carouselContextKey","getCurrentInstance","debugWarn","ref","computed","unref","isUndefined","onMounted","reactive","onUnmounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAA,MAAA,EAAA,GAAAA,mBAAA,UAAA,CAAA,CAAA;AACA,IAAA,MAAA,cAAA,GAAA,gBAAA,CAAA;AAEA,IAAA,MAAA,eAAA,GAAAC,WAAAC,2BAAA,CAAA,CAAA;AAEA,IAAA,MAAA,WAAAC,sBAAA,EAAA,CAAA;AACA,IAAA,IAAA,CAAA,eAAA,EAAA;AACA,MAAAC,eAAA,CACA,gBACA,uDACA,CAAA,CAAA;AAAA,KACA;AAEA,IAAA,IAAA,CAAA,QAAA,EAAA;AACA,MAAAA,eAAA,CACA,gBACA,sDACA,CAAA,CAAA;AAAA,KACA;AAEA,IAAA,MAAA,UAAA,GAAA,IAAA,CAAA;AAEA,IAAA,M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AA,WAAA,CAAA,CAAA;AACA,QAAA,KAAA,CAAA,KAAA,GAAAG,SAAA,CAAA,MAAA,CAAA,GAAA,CAAA,GAAA,UAAA,CAAA;AAAA,OACA,MAAA;AAEA,QAAA,SAAA,CAAA,KAAA,GAAA,aAAA,CAAA,KAAA,EAAA,WAAA,EAAA,WAAA,CAAA,CAAA;AAAA,OACA;AAGA,MAAA,KAAA,CAAA,KAAA,GAAA,IAAA,CAAA;AACA,KAAA,CAAA;AAAA,IACAE,aAAA,CAAA,MAAA;AAAA,MAAA,eACA,CAAA,OAAA,CAAA;AAAA,QACA,KAAA;AAAA,QACA,MAAA,EAAAC,YAAA,CAAA;AAAA,UACA,KAAA;AAAA,UACA,SAAA;AAAA,UACA,KAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA;AAAA,UACA,OAAA;AAAA,mBACA;AAAA,SACA,CAAA;AAAA,QACA,GAAA,EAAA,QAAA,CAAA,GAAA;AAAA,QACA,aAAA;AAEA,OAAA,CAAA,CAAA;AACA,KAAA,CAAA,CAAA;AAAA,IACAC,eAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"carousel-item.js","sources":["../../../../../../packages/components/carousel/src/carousel-item.ts"],"sourcesContent":["import { buildProps } from '@element-ps/utils'\nimport type { ExtractPropTypes } from 'vue'\nimport type CarouselItem from './carousel-item.vue'\n\nexport const carouselItemProps = buildProps({\n name: { type: String, default: '' },\n label: {\n type: [String, Number],\n default: '',\n },\n} as const)\n\nexport type CarouselItemProps = ExtractPropTypes<typeof carouselItemProps>\n\nexport type CarouselItemInstance = InstanceType<typeof CarouselItem>\n"],"names":["buildProps"],"mappings":";;;;;;;AACY,MAAC,iBAAiB,GAAGA,gBAAU,CAAC;AAC5C,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;AACrC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,CAAC;;;;"}
@@ -2,16 +2,157 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var vue = require('vue');
5
6
  require('../../../utils/index.js');
6
- var props = require('../../../utils/vue/props.js');
7
+ require('../../../hooks/index.js');
8
+ require('../../../tokens/index.js');
9
+ var carouselItem = require('./carousel-item.js');
10
+ var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
11
+ var index = require('../../../hooks/use-namespace/index.js');
12
+ var carousel = require('../../../tokens/carousel.js');
13
+ var error = require('../../../utils/error.js');
14
+ var types = require('../../../utils/types.js');
7
15
 
8
- const carouselItemProps = props.buildProps({
9
- name: { type: String, default: "" },
10
- label: {
11
- type: [String, Number],
12
- default: ""
16
+ const __default__ = {
17
+ name: "PsCarouselItem"
18
+ };
19
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
20
+ ...__default__,
21
+ props: carouselItem.carouselItemProps,
22
+ setup(__props) {
23
+ const props = __props;
24
+ const ns = index.useNamespace("carousel");
25
+ const COMPONENT_NAME = "PsCarouselItem";
26
+ const carouselContext = vue.inject(carousel.carouselContextKey);
27
+ const instance = vue.getCurrentInstance();
28
+ if (!carouselContext) {
29
+ error.debugWarn(COMPONENT_NAME, "usage: <ps-carousel></ps-carousel-item></ps-carousel>");
30
+ }
31
+ if (!instance) {
32
+ error.debugWarn(COMPONENT_NAME, "compositional hook can only be invoked inside setups");
33
+ }
34
+ const CARD_SCALE = 0.83;
35
+ const hover = vue.ref(false);
36
+ const translate = vue.ref(0);
37
+ const scale = vue.ref(1);
38
+ const active = vue.ref(false);
39
+ const ready = vue.ref(false);
40
+ const inStage = vue.ref(false);
41
+ const animating = vue.ref(false);
42
+ const { isCardType, isVertical } = carouselContext;
43
+ const itemStyle = vue.computed(() => {
44
+ const translateType = `translate${vue.unref(isVertical) ? "Y" : "X"}`;
45
+ const _translate = `${translateType}(${vue.unref(translate)}px)`;
46
+ const _scale = `scale(${vue.unref(scale)})`;
47
+ const transform = [_translate, _scale].join(" ");
48
+ return {
49
+ transform
50
+ };
51
+ });
52
+ function processIndex(index, activeIndex, length) {
53
+ const lastItemIndex = length - 1;
54
+ const prevItemIndex = activeIndex - 1;
55
+ const nextItemIndex = activeIndex + 1;
56
+ const halfItemIndex = length / 2;
57
+ if (activeIndex === 0 && index === lastItemIndex) {
58
+ return -1;
59
+ } else if (activeIndex === lastItemIndex && index === 0) {
60
+ return length;
61
+ } else if (index < prevItemIndex && activeIndex - index >= halfItemIndex) {
62
+ return length + 1;
63
+ } else if (index > nextItemIndex && index - activeIndex >= halfItemIndex) {
64
+ return -2;
65
+ }
66
+ return index;
67
+ }
68
+ function calcCardTranslate(index, activeIndex) {
69
+ var _a;
70
+ const parentWidth = ((_a = carouselContext.root.value) == null ? void 0 : _a.offsetWidth) || 0;
71
+ if (inStage.value) {
72
+ return parentWidth * ((2 - CARD_SCALE) * (index - activeIndex) + 1) / 4;
73
+ } else if (index < activeIndex) {
74
+ return -(1 + CARD_SCALE) * parentWidth / 4;
75
+ } else {
76
+ return (3 + CARD_SCALE) * parentWidth / 4;
77
+ }
78
+ }
79
+ function calcTranslate(index, activeIndex, isVertical2) {
80
+ const rootEl = carouselContext.root.value;
81
+ if (!rootEl)
82
+ return 0;
83
+ const distance = (isVertical2 ? rootEl.offsetHeight : rootEl.offsetWidth) || 0;
84
+ return distance * (index - activeIndex);
85
+ }
86
+ const translateItem = (index, activeIndex, oldIndex) => {
87
+ var _a;
88
+ const _isCardType = vue.unref(isCardType);
89
+ const carouselItemLength = (_a = carouselContext.items.value.length) != null ? _a : Number.NaN;
90
+ const isActive = index === activeIndex;
91
+ if (!_isCardType && !types.isUndefined(oldIndex)) {
92
+ animating.value = isActive || index === oldIndex;
93
+ }
94
+ if (!isActive && carouselItemLength > 2 && carouselContext.loop) {
95
+ index = processIndex(index, activeIndex, carouselItemLength);
96
+ }
97
+ const _isVertical = vue.unref(isVertical);
98
+ active.value = isActive;
99
+ if (_isCardType) {
100
+ if (_isVertical) {
101
+ error.debugWarn("Carousel", "vertical direction is not supported for card mode");
102
+ }
103
+ inStage.value = Math.round(Math.abs(index - activeIndex)) <= 1;
104
+ translate.value = calcCardTranslate(index, activeIndex);
105
+ scale.value = vue.unref(active) ? 1 : CARD_SCALE;
106
+ } else {
107
+ translate.value = calcTranslate(index, activeIndex, _isVertical);
108
+ }
109
+ ready.value = true;
110
+ };
111
+ vue.onMounted(() => {
112
+ carouselContext.addItem({
113
+ props,
114
+ states: vue.reactive({
115
+ hover,
116
+ translate,
117
+ scale,
118
+ active,
119
+ ready,
120
+ inStage,
121
+ animating
122
+ }),
123
+ uid: instance.uid,
124
+ translateItem
125
+ });
126
+ });
127
+ vue.onUnmounted(() => {
128
+ carouselContext.removeItem(instance.uid);
129
+ });
130
+ return (_ctx, _cache) => {
131
+ return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
132
+ class: vue.normalizeClass([
133
+ vue.unref(ns).e("item"),
134
+ vue.unref(ns).is("active", active.value),
135
+ vue.unref(ns).is("in-stage", inStage.value),
136
+ vue.unref(ns).is("hover", hover.value),
137
+ vue.unref(ns).is("animating", animating.value),
138
+ { [vue.unref(ns).em("item", "card")]: vue.unref(isCardType) }
139
+ ]),
140
+ style: vue.normalizeStyle(vue.unref(itemStyle))
141
+ }, [
142
+ vue.unref(isCardType) ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
143
+ key: 0,
144
+ class: vue.normalizeClass(vue.unref(ns).e("mask"))
145
+ }, null, 2)), [
146
+ [vue.vShow, !active.value]
147
+ ]) : vue.createCommentVNode("v-if", true),
148
+ vue.renderSlot(_ctx.$slots, "default")
149
+ ], 6)), [
150
+ [vue.vShow, ready.value]
151
+ ]);
152
+ };
13
153
  }
14
154
  });
155
+ var CarouselItem = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/carousel/src/carousel-item.vue"]]);
15
156
 
16
- exports.carouselItemProps = carouselItemProps;
157
+ exports["default"] = CarouselItem;
17
158
  //# sourceMappingURL=carousel-item2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"carousel-item2.js","sources":["../../../../../../packages/components/carousel/src/carousel-item.ts"],"sourcesContent":["import { buildProps } from '@element-ps/utils'\nimport type { ExtractPropTypes } from 'vue'\nimport type CarouselItem from './carousel-item.vue'\n\nexport const carouselItemProps = buildProps({\n name: { type: String, default: '' },\n label: {\n type: [String, Number],\n default: '',\n },\n} as const)\n\nexport type CarouselItemProps = ExtractPropTypes<typeof carouselItemProps>\n\nexport type CarouselItemInstance = InstanceType<typeof CarouselItem>\n"],"names":["buildProps"],"mappings":";;;;;;;AACY,MAAC,iBAAiB,GAAGA,gBAAU,CAAC;AAC5C,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;AACrC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,CAAC;;;;"}
1
+ {"version":3,"file":"carousel-item2.js","sources":["../../../../../../packages/components/carousel/src/carousel-item.vue"],"sourcesContent":["<template>\n <div\n v-show=\"ready\"\n :class=\"[\n ns.e('item'),\n ns.is('active', active),\n ns.is('in-stage', inStage),\n ns.is('hover', hover),\n ns.is('animating', animating),\n { [ns.em('item', 'card')]: isCardType },\n ]\"\n :style=\"itemStyle\"\n >\n <div v-if=\"isCardType\" v-show=\"!active\" :class=\"ns.e('mask')\" />\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport {\n computed,\n getCurrentInstance,\n inject,\n onMounted,\n onUnmounted,\n reactive,\n ref,\n unref,\n} from 'vue'\nimport { debugWarn, isUndefined } from '@element-ps/utils'\nimport { useNamespace } from '@element-ps/hooks'\nimport { carouselContextKey } from '@element-ps/tokens'\nimport { carouselItemProps } from './carousel-item'\n\nimport type { CSSProperties } from 'vue'\n\ndefineOptions({\n name: 'PsCarouselItem',\n})\n\nconst props = defineProps(carouselItemProps)\nconst ns = useNamespace('carousel')\nconst COMPONENT_NAME = 'PsCarouselItem'\n// inject\nconst carouselContext = inject(carouselContextKey)!\n// instance\nconst instance = getCurrentInstance()!\nif (!carouselContext) {\n debugWarn(\n COMPONENT_NAME,\n 'usage: <ps-carousel></ps-carousel-item></ps-carousel>'\n )\n}\n\nif (!instance) {\n debugWarn(\n COMPONENT_NAME,\n 'compositional hook can only be invoked inside setups'\n )\n}\n\nconst CARD_SCALE = 0.83\n\nconst hover = ref(false)\nconst translate = ref(0)\nconst scale = ref(1)\nconst active = ref(false)\nconst ready = ref(false)\nconst inStage = ref(false)\nconst animating = ref(false)\n\n// computed\nconst { isCardType, isVertical } = carouselContext\n\nconst itemStyle = computed<CSSProperties>(() => {\n const translateType = `translate${unref(isVertical) ? 'Y' : 'X'}`\n const _translate = `${translateType}(${unref(translate)}px)`\n const _scale = `scale(${unref(scale)})`\n const transform = [_translate, _scale].join(' ')\n\n return {\n transform,\n }\n})\n\n// methods\n\nfunction processIndex(index: number, activeIndex: number, length: number) {\n const lastItemIndex = length - 1\n const prevItemIndex = activeIndex - 1\n const nextItemIndex = activeIndex + 1\n const halfItemIndex = length / 2\n\n if (activeIndex === 0 && index === lastItemIndex) {\n return -1\n } else if (activeIndex === lastItemIndex && index === 0) {\n return length\n } else if (index < prevItemIndex && activeIndex - index >= halfItemIndex) {\n return length + 1\n } else if (index > nextItemIndex && index - activeIndex >= halfItemIndex) {\n return -2\n }\n return index\n}\n\nfunction calcCardTranslate(index: number, activeIndex: number) {\n const parentWidth = carouselContext.root.value?.offsetWidth || 0\n if (inStage.value) {\n return (parentWidth * ((2 - CARD_SCALE) * (index - activeIndex) + 1)) / 4\n } else if (index < activeIndex) {\n return (-(1 + CARD_SCALE) * parentWidth) / 4\n } else {\n return ((3 + CARD_SCALE) * parentWidth) / 4\n }\n}\n\nfunction calcTranslate(\n index: number,\n activeIndex: number,\n isVertical: boolean\n) {\n const rootEl = carouselContext.root.value\n if (!rootEl) return 0\n\n const distance = (isVertical ? rootEl.offsetHeight : rootEl.offsetWidth) || 0\n return distance * (index - activeIndex)\n}\n\nconst translateItem = (\n index: number,\n activeIndex: number,\n oldIndex?: number\n) => {\n const _isCardType = unref(isCardType)\n const carouselItemLength = carouselContext.items.value.length ?? Number.NaN\n\n const isActive = index === activeIndex\n if (!_isCardType && !isUndefined(oldIndex)) {\n animating.value = isActive || index === oldIndex\n }\n\n if (!isActive && carouselItemLength > 2 && carouselContext.loop) {\n index = processIndex(index, activeIndex, carouselItemLength)\n }\n\n const _isVertical = unref(isVertical)\n active.value = isActive\n\n if (_isCardType) {\n if (_isVertical) {\n debugWarn('Carousel', 'vertical direction is not supported for card mode')\n }\n inStage.value = Math.round(Math.abs(index - activeIndex)) <= 1\n translate.value = calcCardTranslate(index, activeIndex)\n scale.value = unref(active) ? 1 : CARD_SCALE\n } else {\n translate.value = calcTranslate(index, activeIndex, _isVertical)\n }\n\n ready.value = true\n}\n\n// lifecycle\nonMounted(() => {\n carouselContext.addItem({\n props,\n states: reactive({\n hover,\n translate,\n scale,\n active,\n ready,\n inStage,\n animating,\n }),\n uid: instance.uid,\n translateItem,\n })\n})\n\nonUnmounted(() => {\n carouselContext.removeItem(instance.uid)\n})\n</script>\n"],"names":["useNamespace","inject","carouselContextKey","getCurrentInstance","debugWarn","ref","computed","unref","isUndefined","onMounted","reactive","onUnmounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAA,MAAA,EAAA,GAAAA,mBAAA,UAAA,CAAA,CAAA;AACA,IAAA,MAAA,cAAA,GAAA,gBAAA,CAAA;AAEA,IAAA,MAAA,eAAA,GAAAC,WAAAC,2BAAA,CAAA,CAAA;AAEA,IAAA,MAAA,WAAAC,sBAAA,EAAA,CAAA;AACA,IAAA,IAAA,CAAA,eAAA,EA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CAAA,CAAA;AACA,SAAA;AACA,QAAA,OAAA,CAAA,KAAA,GAAA,IAAA,CAAA,KAAA,CAAA,IAAA,CAAA,GAAA,CAAA,KAAA,GAAA,WAAA,CAAA,CAAA,IAAA,CAAA,CAAA;AAAA,QACA,SAAA,CAAA,KAAA,GAAA,iBAAA,CAAA,KAAA,EAAA,WAAA,CAAA,CAAA;AACA,QAAA,KAAA,CAAA,KAAA,GAAAG,SAAA,CAAA,MAAA,CAAA,GAAA,CAAA,GAAA,UAAA,CAAA;AAAA,OACA,MAAA;AAEA,QAAA,SAAA,CAAA,KAAA,GAAA,aAAA,CAAA,KAAA,EAAA,WAAA,EAAA,WAAA,CAAA,CAAA;AAAA,OACA;AAGA,MAAA,KAAA,CAAA,KAAA,GAAA,IAAA,CAAA;AACA,KAAA,CAAA;AAAA,IACAE,aAAA,CAAA,MAAA;AAAA,MAAA,eACA,CAAA,OAAA,CAAA;AAAA,QACA,KAAA;AAAA,QACA,MAAA,EAAAC,YAAA,CAAA;AAAA,UACA,KAAA;AAAA,UACA,SAAA;AAAA,UACA,KAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA;AAAA,UACA,OAAA;AAAA,mBACA;AAAA,SACA,CAAA;AAAA,QACA,GAAA,EAAA,QAAA,CAAA,GAAA;AAAA,QACA,aAAA;AAEA,OAAA,CAAA,CAAA;AACA,KAAA,CAAA,CAAA;AAAA,IACAC,eAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,211 +2,53 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var vue = require('vue');
6
- var core = require('@vueuse/core');
7
5
  require('../../../utils/index.js');
8
- var index$1 = require('../../icon/index.js');
9
- var iconsVue = require('@element-plus/icons-vue');
10
- require('../../../hooks/index.js');
11
- require('../../../tokens/index.js');
12
- var carousel = require('./carousel2.js');
13
- var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
14
- var index = require('../../../hooks/use-namespace/index.js');
15
- var shared = require('@vue/shared');
16
- var error = require('../../../utils/error.js');
17
- var carousel$1 = require('../../../tokens/carousel.js');
6
+ var props = require('../../../utils/vue/props.js');
18
7
 
19
- const _hoisted_1 = { key: 0 };
20
- const __default__ = {
21
- name: "PsCarousel"
22
- };
23
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
24
- ...__default__,
25
- props: carousel.carouselProps,
26
- setup(__props, { expose }) {
27
- const props = __props;
28
- const ns = index.useNamespace("carousel");
29
- const COMPONENT_NAME = "PsCarousel";
30
- const THROTTLE_TIME = 300;
31
- const activeIndex = vue.ref(-1);
32
- const timer = vue.ref(null);
33
- const hover = vue.ref(false);
34
- const root = vue.ref();
35
- const items = vue.ref([]);
36
- const arrowDisplay = vue.computed(() => props.arrow !== "never" && !vue.unref(isVertical));
37
- const hasLabel = vue.computed(() => {
38
- return items.value.some((item) => item.props.label.toString().length > 0);
39
- });
40
- const carouselClasses = vue.computed(() => {
41
- const classes = [ns.b(), ns.m(props.direction)];
42
- if (vue.unref(isCardType)) {
43
- classes.push(ns.m("card"));
44
- }
45
- return classes;
46
- });
47
- const indicatorsClasses = vue.computed(() => {
48
- const classes = [ns.e("indicators"), ns.em("indicators", props.direction)];
49
- if (hasLabel.value) {
50
- classes.push(ns.em("indicators", "labels"));
51
- }
52
- if (props.indicatorPosition === "outside" || vue.unref(isCardType)) {
53
- classes.push(ns.em("indicators", "outside"));
54
- }
55
- return classes;
56
- });
57
- const isCardType = vue.computed(() => props.type === "card");
58
- const isVertical = vue.computed(() => props.direction === "vertical");
59
- function pauseTimer() {
60
- if (timer.value) {
61
- clearInterval(timer.value);
62
- timer.value = null;
63
- }
8
+ const carouselProps = props.buildProps({
9
+ initialIndex: {
10
+ type: Number,
11
+ default: 0
12
+ },
13
+ height: { type: String, default: "" },
14
+ trigger: {
15
+ type: String,
16
+ default: "hover"
17
+ },
18
+ autoplay: {
19
+ type: Boolean,
20
+ default: true
21
+ },
22
+ interval: {
23
+ type: Number,
24
+ default: 3e3
25
+ },
26
+ indicatorPosition: { type: String, default: "" },
27
+ indicator: {
28
+ type: Boolean,
29
+ default: true
30
+ },
31
+ arrow: {
32
+ type: String,
33
+ default: "hover"
34
+ },
35
+ type: { type: String, default: "" },
36
+ loop: {
37
+ type: Boolean,
38
+ default: true
39
+ },
40
+ direction: {
41
+ type: String,
42
+ default: "horizontal",
43
+ validator(val) {
44
+ return ["horizontal", "vertical"].includes(val);
64
45
  }
65
- function startTimer() {
66
- if (props.interval <= 0 || !props.autoplay || timer.value)
67
- return;
68
- timer.value = setInterval(() => playSlides(), props.interval);
69
- }
70
- const playSlides = () => {
71
- if (activeIndex.value < items.value.length - 1) {
72
- activeIndex.value = activeIndex.value + 1;
73
- } else if (props.loop) {
74
- activeIndex.value = 0;
75
- }
76
- };
77
- function setActiveItem(index) {
78
- if (shared.isString(index)) {
79
- const filteredItems = items.value.filter((item) => item.props.name === index);
80
- if (filteredItems.length > 0) {
81
- index = items.value.indexOf(filteredItems[0]);
82
- }
83
- }
84
- index = Number(index);
85
- if (Number.isNaN(index) || index !== Math.floor(index)) {
86
- error.debugWarn(COMPONENT_NAME, "index must be integer.");
87
- return;
88
- }
89
- const itemCount = items.value.length;
90
- const oldIndex = activeIndex.value;
91
- if (index < 0) {
92
- activeIndex.value = props.loop ? itemCount - 1 : 0;
93
- } else if (index >= itemCount) {
94
- activeIndex.value = props.loop ? 0 : itemCount - 1;
95
- } else {
96
- activeIndex.value = index;
97
- }
98
- if (oldIndex === activeIndex.value) {
99
- resetItemPosition(oldIndex);
100
- }
101
- }
102
- function resetItemPosition(oldIndex) {
103
- items.value.forEach((item, index) => {
104
- item.translateItem(index, activeIndex.value, oldIndex);
105
- });
106
- }
107
- function addItem(item) {
108
- items.value.push(item);
109
- }
110
- function removeItem(uid) {
111
- const index = items.value.findIndex((item) => item.uid === uid);
112
- if (index !== -1) {
113
- items.value.splice(index, 1);
114
- if (activeIndex.value === index)
115
- next();
116
- }
117
- }
118
- function next() {
119
- setActiveItem(activeIndex.value + 1);
120
- }
121
- const resizeObserver = vue.shallowRef();
122
- vue.onMounted(async () => {
123
- await vue.nextTick();
124
- resizeObserver.value = core.useResizeObserver(root.value, () => {
125
- resetItemPosition();
126
- });
127
- if (props.initialIndex < items.value.length && props.initialIndex >= 0) {
128
- activeIndex.value = props.initialIndex;
129
- }
130
- startTimer();
131
- });
132
- vue.onBeforeUnmount(() => {
133
- pauseTimer();
134
- if (root.value && resizeObserver.value)
135
- resizeObserver.value.stop();
136
- });
137
- vue.provide(carousel$1.carouselContextKey, {
138
- root,
139
- isCardType,
140
- isVertical,
141
- items,
142
- loop: props.loop,
143
- addItem,
144
- removeItem,
145
- setActiveItem
146
- });
147
- expose({
148
- setActiveItem
149
- });
150
- return (_ctx, _cache) => {
151
- return vue.openBlock(), vue.createElementBlock("div", {
152
- ref_key: "root",
153
- ref: root,
154
- class: vue.normalizeClass(vue.unref(carouselClasses))
155
- }, [
156
- vue.createElementVNode("div", {
157
- class: vue.normalizeClass(vue.unref(ns).e("container")),
158
- style: vue.normalizeStyle({ height: _ctx.height })
159
- }, [
160
- vue.createElementVNode("button", {
161
- type: "button",
162
- class: vue.normalizeClass([vue.unref(ns).e("arrow"), vue.unref(ns).em("arrow", "left")])
163
- }, [
164
- vue.createVNode(vue.unref(index$1.PsIcon), null, {
165
- default: vue.withCtx(() => [
166
- vue.createVNode(vue.unref(iconsVue.ArrowLeft))
167
- ]),
168
- _: 1
169
- })
170
- ], 2),
171
- vue.createElementVNode("button", {
172
- type: "button",
173
- class: vue.normalizeClass([vue.unref(ns).e("arrow"), vue.unref(ns).em("arrow", "right")])
174
- }, [
175
- vue.createVNode(vue.unref(index$1.PsIcon), null, {
176
- default: vue.withCtx(() => [
177
- vue.createVNode(vue.unref(iconsVue.ArrowRight))
178
- ]),
179
- _: 1
180
- })
181
- ], 2),
182
- vue.renderSlot(_ctx.$slots, "default")
183
- ], 6),
184
- _ctx.indicatorPosition !== "none" ? (vue.openBlock(), vue.createElementBlock("ul", {
185
- key: 0,
186
- class: vue.normalizeClass(vue.unref(indicatorsClasses))
187
- }, [
188
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(items.value, (item, index) => {
189
- return vue.openBlock(), vue.createElementBlock("li", {
190
- key: index,
191
- class: vue.normalizeClass([
192
- vue.unref(ns).e("indicator"),
193
- vue.unref(ns).em("indicator", _ctx.direction),
194
- vue.unref(ns).is("active", index === activeIndex.value)
195
- ])
196
- }, [
197
- vue.createElementVNode("button", {
198
- class: vue.normalizeClass(vue.unref(ns).e("button"))
199
- }, [
200
- vue.unref(hasLabel) ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, vue.toDisplayString(item.props.label), 1)) : vue.createCommentVNode("v-if", true)
201
- ], 2)
202
- ], 2);
203
- }), 128))
204
- ], 2)) : vue.createCommentVNode("v-if", true)
205
- ], 2);
206
- };
46
+ },
47
+ pauseOnHover: {
48
+ type: Boolean,
49
+ default: true
207
50
  }
208
51
  });
209
- var Carousel = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/carousel/src/carousel.vue"]]);
210
52
 
211
- exports["default"] = Carousel;
53
+ exports.carouselProps = carouselProps;
212
54
  //# sourceMappingURL=carousel.js.map