@element-plus/nightly 0.0.20220105 → 0.0.20220109

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 (380) hide show
  1. package/README.md +27 -82
  2. package/attributes.json +1 -1
  3. package/dist/index.css +1 -1
  4. package/dist/index.full.js +288 -219
  5. package/dist/index.full.min.js +8 -8
  6. package/dist/index.full.min.js.map +1 -1
  7. package/dist/index.full.min.mjs +8 -8
  8. package/dist/index.full.min.mjs.map +1 -1
  9. package/dist/index.full.mjs +286 -216
  10. package/es/components/autocomplete/src/index.vue_vue_type_script_lang.mjs.map +1 -1
  11. package/es/components/autocomplete/src/index.vue_vue_type_template_id_2f09f285_lang.mjs +1 -0
  12. package/es/components/autocomplete/src/index.vue_vue_type_template_id_2f09f285_lang.mjs.map +1 -1
  13. package/es/components/cascader/index.d.ts +4 -0
  14. package/es/components/cascader/src/index.vue.d.ts +2 -0
  15. package/es/components/cascader-panel/src/index.vue_vue_type_script_lang.mjs +5 -4
  16. package/es/components/cascader-panel/src/index.vue_vue_type_script_lang.mjs.map +1 -1
  17. package/es/components/cascader-panel/src/index.vue_vue_type_template_id_97c48f5c_lang.mjs.map +1 -1
  18. package/es/components/cascader-panel/src/menu.vue.d.ts +1 -0
  19. package/es/components/cascader-panel/src/menu.vue_vue_type_script_lang.mjs +6 -0
  20. package/es/components/cascader-panel/src/menu.vue_vue_type_script_lang.mjs.map +1 -1
  21. package/es/components/cascader-panel/src/menu.vue_vue_type_template_id_9c79e4e2_lang.mjs +19 -2
  22. package/es/components/cascader-panel/src/menu.vue_vue_type_template_id_9c79e4e2_lang.mjs.map +1 -1
  23. package/es/components/cascader-panel/src/types.d.ts +1 -0
  24. package/es/components/cascader-panel/src/types.mjs.map +1 -1
  25. package/es/components/checkbox/index.d.ts +6 -6
  26. package/es/components/checkbox/src/checkbox-button.vue.d.ts +2 -2
  27. package/es/components/checkbox/src/checkbox.vue.d.ts +2 -2
  28. package/es/components/color-picker/src/index.vue_vue_type_script_lang.mjs.map +1 -1
  29. package/es/components/color-picker/src/index.vue_vue_type_template_id_46a474d5_lang.mjs +2 -1
  30. package/es/components/color-picker/src/index.vue_vue_type_template_id_46a474d5_lang.mjs.map +1 -1
  31. package/es/components/config-provider/index.d.ts +6 -2
  32. package/es/components/config-provider/index.mjs +1 -1
  33. package/es/components/config-provider/src/config-provider.d.ts +13 -5
  34. package/es/components/config-provider/src/config-provider.mjs +12 -5
  35. package/es/components/config-provider/src/config-provider.mjs.map +1 -1
  36. package/es/components/date-picker/index.d.ts +4 -4
  37. package/es/components/date-picker/src/date-picker-com/basic-cell-render.mjs +1 -1
  38. package/es/components/date-picker/src/date-picker-com/basic-cell-render.mjs.map +1 -1
  39. package/es/components/date-picker/src/date-picker.d.ts +2 -2
  40. package/es/components/dropdown/src/dropdown.vue_vue_type_script_lang.mjs.map +1 -1
  41. package/es/components/dropdown/src/dropdown.vue_vue_type_template_id_3ed790a5_lang.mjs +1 -0
  42. package/es/components/dropdown/src/dropdown.vue_vue_type_template_id_3ed790a5_lang.mjs.map +1 -1
  43. package/es/components/form/index.d.ts +1 -0
  44. package/es/components/form/src/form.vue.d.ts +1 -0
  45. package/es/components/form/src/form.vue_vue_type_script_lang.mjs +14 -0
  46. package/es/components/form/src/form.vue_vue_type_script_lang.mjs.map +1 -1
  47. package/es/components/form/src/form.vue_vue_type_template_id_602d6cf6_lang.mjs +1 -4
  48. package/es/components/form/src/form.vue_vue_type_template_id_602d6cf6_lang.mjs.map +1 -1
  49. package/es/components/index.mjs +3 -3
  50. package/es/components/input/index.d.ts +1 -0
  51. package/es/components/input/src/input.vue.d.ts +1 -0
  52. package/es/components/input/src/input.vue_vue_type_script_lang.mjs +1 -0
  53. package/es/components/input/src/input.vue_vue_type_script_lang.mjs.map +1 -1
  54. package/es/components/input/src/input.vue_vue_type_template_id_3290dcb6_lang.mjs +1 -1
  55. package/es/components/input/src/input.vue_vue_type_template_id_3290dcb6_lang.mjs.map +1 -1
  56. package/es/components/input-number/index.d.ts +5 -1
  57. package/es/components/input-number/src/input-number.vue.d.ts +5 -1
  58. package/es/components/input-number/src/input-number.vue_vue_type_script_lang.mjs +15 -1
  59. package/es/components/input-number/src/input-number.vue_vue_type_script_lang.mjs.map +1 -1
  60. package/es/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.mjs +5 -4
  61. package/es/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.mjs.map +1 -1
  62. package/es/components/menu/src/menu-item.vue_vue_type_script_lang.mjs.map +1 -1
  63. package/es/components/menu/src/menu-item.vue_vue_type_template_id_aa755baa_lang.mjs +2 -1
  64. package/es/components/menu/src/menu-item.vue_vue_type_template_id_aa755baa_lang.mjs.map +1 -1
  65. package/es/components/message/src/message-method.mjs +5 -1
  66. package/es/components/message/src/message-method.mjs.map +1 -1
  67. package/es/components/message/src/message.d.ts +3 -0
  68. package/es/components/message/src/message.mjs.map +1 -1
  69. package/es/components/message/src/message.vue.d.ts +2 -2
  70. package/es/components/message-box/src/index.vue_vue_type_script_lang.mjs.map +1 -1
  71. package/es/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.mjs +1 -0
  72. package/es/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.mjs.map +1 -1
  73. package/es/components/notification/src/notification.vue.d.ts +4 -4
  74. package/es/components/popconfirm/src/popconfirm.vue_vue_type_script_lang.mjs.map +1 -1
  75. package/es/components/popconfirm/src/popconfirm.vue_vue_type_template_id_16409d25_lang.mjs +2 -1
  76. package/es/components/popconfirm/src/popconfirm.vue_vue_type_template_id_16409d25_lang.mjs.map +1 -1
  77. package/es/components/popover/src/index.vue_vue_type_script_lang.mjs.map +1 -1
  78. package/es/components/popover/src/index.vue_vue_type_template_id_15486cf0_lang.mjs +2 -1
  79. package/es/components/popover/src/index.vue_vue_type_template_id_15486cf0_lang.mjs.map +1 -1
  80. package/es/components/popper/src/content.vue_vue_type_script_lang.mjs.map +1 -1
  81. package/es/components/popper/src/content.vue_vue_type_template_id_611b76f0_lang.mjs +1 -0
  82. package/es/components/popper/src/content.vue_vue_type_template_id_611b76f0_lang.mjs.map +1 -1
  83. package/es/components/radio/index.d.ts +6 -6
  84. package/es/components/radio/index.mjs +2 -2
  85. package/es/components/radio/src/radio-button.mjs +11 -5
  86. package/es/components/radio/src/radio-button.mjs.map +1 -1
  87. package/es/components/radio/src/radio-button.vue.d.ts +2 -2
  88. package/es/components/radio/src/radio-button.vue_vue_type_script_lang.mjs +1 -1
  89. package/es/components/radio/src/radio-button2.mjs +5 -11
  90. package/es/components/radio/src/radio-button2.mjs.map +1 -1
  91. package/es/components/radio/src/radio.vue.d.ts +2 -2
  92. package/es/components/rate/index.d.ts +7 -1
  93. package/es/components/rate/src/rate.d.ts +2 -0
  94. package/es/components/rate/src/rate.mjs +5 -0
  95. package/es/components/rate/src/rate.mjs.map +1 -1
  96. package/es/components/rate/src/rate.vue.d.ts +7 -1
  97. package/es/components/rate/src/rate.vue_vue_type_script_lang.mjs +6 -0
  98. package/es/components/rate/src/rate.vue_vue_type_script_lang.mjs.map +1 -1
  99. package/es/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.mjs +3 -3
  100. package/es/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.mjs.map +1 -1
  101. package/es/components/select/index.d.ts +1 -1
  102. package/es/components/select/src/select.vue.d.ts +1 -1
  103. package/es/components/select/src/select.vue_vue_type_script_lang.mjs.map +1 -1
  104. package/es/components/select/src/select.vue_vue_type_template_id_33774f85_lang.mjs +1 -0
  105. package/es/components/select/src/select.vue_vue_type_template_id_33774f85_lang.mjs.map +1 -1
  106. package/es/components/select-v2/index.d.ts +2 -2
  107. package/es/components/select-v2/src/select.vue.d.ts +1 -1
  108. package/es/components/select-v2/src/select.vue_vue_type_script_lang.mjs.map +1 -1
  109. package/es/components/select-v2/src/select.vue_vue_type_template_id_13e598a4_lang.mjs +1 -0
  110. package/es/components/select-v2/src/select.vue_vue_type_template_id_13e598a4_lang.mjs.map +1 -1
  111. package/es/components/skeleton/index.mjs +2 -2
  112. package/es/components/skeleton/src/skeleton.mjs +24 -5
  113. package/es/components/skeleton/src/skeleton.mjs.map +1 -1
  114. package/es/components/skeleton/src/skeleton.vue_vue_type_script_lang.mjs +1 -1
  115. package/es/components/skeleton/src/skeleton2.mjs +5 -24
  116. package/es/components/skeleton/src/skeleton2.mjs.map +1 -1
  117. package/es/components/slider/index.d.ts +22 -6
  118. package/es/components/slider/src/button.vue_vue_type_script_lang.mjs.map +1 -1
  119. package/es/components/slider/src/button.vue_vue_type_template_id_9cd3e794_lang.mjs +2 -1
  120. package/es/components/slider/src/button.vue_vue_type_template_id_9cd3e794_lang.mjs.map +1 -1
  121. package/es/components/slider/src/index.vue.d.ts +11 -3
  122. package/es/components/slider/src/index.vue_vue_type_script_lang.mjs +21 -2
  123. package/es/components/slider/src/index.vue_vue_type_script_lang.mjs.map +1 -1
  124. package/es/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.mjs +19 -19
  125. package/es/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.mjs.map +1 -1
  126. package/es/components/switch/index.d.ts +7 -2
  127. package/es/components/switch/src/switch.d.ts +2 -0
  128. package/es/components/switch/src/switch.mjs +5 -0
  129. package/es/components/switch/src/switch.mjs.map +1 -1
  130. package/es/components/switch/src/switch.vue.d.ts +7 -2
  131. package/es/components/switch/src/switch.vue_vue_type_script_lang.mjs +10 -1
  132. package/es/components/switch/src/switch.vue_vue_type_script_lang.mjs.map +1 -1
  133. package/es/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.mjs +1 -1
  134. package/es/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.mjs.map +1 -1
  135. package/es/components/table/src/filter-panel.vue_vue_type_script_lang.mjs.map +1 -1
  136. package/es/components/table/src/filter-panel.vue_vue_type_template_id_fde1c940_lang.mjs +2 -1
  137. package/es/components/table/src/filter-panel.vue_vue_type_template_id_fde1c940_lang.mjs.map +1 -1
  138. package/es/components/table/src/table-layout.mjs +1 -2
  139. package/es/components/table/src/table-layout.mjs.map +1 -1
  140. package/es/components/table/src/util.d.ts +2 -2
  141. package/es/components/table/src/util.mjs +9 -5
  142. package/es/components/table/src/util.mjs.map +1 -1
  143. package/es/components/tabs/index.d.ts +4 -4
  144. package/es/components/tabs/src/tab-pane.vue.d.ts +2 -2
  145. package/es/components/time-picker/index.d.ts +4 -4
  146. package/es/components/time-picker/src/common/picker.vue.d.ts +2 -2
  147. package/es/components/time-picker/src/common/picker.vue_vue_type_script_lang.mjs +6 -2
  148. package/es/components/time-picker/src/common/picker.vue_vue_type_script_lang.mjs.map +1 -1
  149. package/es/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.mjs +1 -0
  150. package/es/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.mjs.map +1 -1
  151. package/es/components/time-picker/src/time-picker.d.ts +2 -2
  152. package/es/components/transfer/src/transfer-panel.vue.d.ts +1 -2
  153. package/es/components/transfer/src/transfer-panel.vue_vue_type_script_lang.mjs +2 -13
  154. package/es/components/transfer/src/transfer-panel.vue_vue_type_script_lang.mjs.map +1 -1
  155. package/es/components/transfer/src/transfer-panel.vue_vue_type_template_id_1a7d1f9c_lang.mjs +5 -18
  156. package/es/components/transfer/src/transfer-panel.vue_vue_type_template_id_1a7d1f9c_lang.mjs.map +1 -1
  157. package/es/defaults.d.ts +3 -1
  158. package/es/hooks/index.mjs +1 -1
  159. package/es/hooks/use-global-config/index.d.ts +3 -1
  160. package/es/hooks/use-global-config/index.mjs +3 -2
  161. package/es/hooks/use-global-config/index.mjs.map +1 -1
  162. package/es/hooks/use-id/index.mjs +2 -2
  163. package/es/hooks/use-id/index.mjs.map +1 -1
  164. package/es/hooks/use-locale/index.d.ts +2 -253
  165. package/es/hooks/use-locale/index.mjs +9 -29
  166. package/es/hooks/use-locale/index.mjs.map +1 -1
  167. package/es/hooks/use-popper-container/index.mjs +2 -2
  168. package/es/hooks/use-popper-container/index.mjs.map +1 -1
  169. package/es/index.d.ts +4 -1
  170. package/es/index.mjs +5 -4
  171. package/es/index.mjs.map +1 -1
  172. package/es/version.d.ts +1 -1
  173. package/es/version.mjs +1 -1
  174. package/es/version.mjs.map +1 -1
  175. package/lib/components/autocomplete/src/index.vue_vue_type_script_lang.js.map +1 -1
  176. package/lib/components/autocomplete/src/index.vue_vue_type_template_id_2f09f285_lang.js +1 -0
  177. package/lib/components/autocomplete/src/index.vue_vue_type_template_id_2f09f285_lang.js.map +1 -1
  178. package/lib/components/cascader/index.d.ts +4 -0
  179. package/lib/components/cascader/src/index.vue.d.ts +2 -0
  180. package/lib/components/cascader-panel/src/index.vue_vue_type_script_lang.js +5 -4
  181. package/lib/components/cascader-panel/src/index.vue_vue_type_script_lang.js.map +1 -1
  182. package/lib/components/cascader-panel/src/index.vue_vue_type_template_id_97c48f5c_lang.js.map +1 -1
  183. package/lib/components/cascader-panel/src/menu.vue.d.ts +1 -0
  184. package/lib/components/cascader-panel/src/menu.vue_vue_type_script_lang.js +10 -4
  185. package/lib/components/cascader-panel/src/menu.vue_vue_type_script_lang.js.map +1 -1
  186. package/lib/components/cascader-panel/src/menu.vue_vue_type_template_id_9c79e4e2_lang.js +18 -1
  187. package/lib/components/cascader-panel/src/menu.vue_vue_type_template_id_9c79e4e2_lang.js.map +1 -1
  188. package/lib/components/cascader-panel/src/types.d.ts +1 -0
  189. package/lib/components/cascader-panel/src/types.js.map +1 -1
  190. package/lib/components/checkbox/index.d.ts +6 -6
  191. package/lib/components/checkbox/src/checkbox-button.vue.d.ts +2 -2
  192. package/lib/components/checkbox/src/checkbox.vue.d.ts +2 -2
  193. package/lib/components/color-picker/src/index.vue_vue_type_script_lang.js.map +1 -1
  194. package/lib/components/color-picker/src/index.vue_vue_type_template_id_46a474d5_lang.js +2 -1
  195. package/lib/components/color-picker/src/index.vue_vue_type_template_id_46a474d5_lang.js.map +1 -1
  196. package/lib/components/config-provider/index.d.ts +6 -2
  197. package/lib/components/config-provider/index.js +1 -0
  198. package/lib/components/config-provider/index.js.map +1 -1
  199. package/lib/components/config-provider/src/config-provider.d.ts +13 -5
  200. package/lib/components/config-provider/src/config-provider.js +13 -5
  201. package/lib/components/config-provider/src/config-provider.js.map +1 -1
  202. package/lib/components/date-picker/index.d.ts +4 -4
  203. package/lib/components/date-picker/src/date-picker-com/basic-cell-render.js +1 -1
  204. package/lib/components/date-picker/src/date-picker-com/basic-cell-render.js.map +1 -1
  205. package/lib/components/date-picker/src/date-picker.d.ts +2 -2
  206. package/lib/components/dropdown/src/dropdown.vue_vue_type_script_lang.js.map +1 -1
  207. package/lib/components/dropdown/src/dropdown.vue_vue_type_template_id_3ed790a5_lang.js +1 -0
  208. package/lib/components/dropdown/src/dropdown.vue_vue_type_template_id_3ed790a5_lang.js.map +1 -1
  209. package/lib/components/form/index.d.ts +1 -0
  210. package/lib/components/form/src/form.vue.d.ts +1 -0
  211. package/lib/components/form/src/form.vue_vue_type_script_lang.js +14 -0
  212. package/lib/components/form/src/form.vue_vue_type_script_lang.js.map +1 -1
  213. package/lib/components/form/src/form.vue_vue_type_template_id_602d6cf6_lang.js +1 -4
  214. package/lib/components/form/src/form.vue_vue_type_template_id_602d6cf6_lang.js.map +1 -1
  215. package/lib/components/index.js +3 -2
  216. package/lib/components/index.js.map +1 -1
  217. package/lib/components/input/index.d.ts +1 -0
  218. package/lib/components/input/src/input.vue.d.ts +1 -0
  219. package/lib/components/input/src/input.vue_vue_type_script_lang.js +1 -0
  220. package/lib/components/input/src/input.vue_vue_type_script_lang.js.map +1 -1
  221. package/lib/components/input/src/input.vue_vue_type_template_id_3290dcb6_lang.js +1 -1
  222. package/lib/components/input/src/input.vue_vue_type_template_id_3290dcb6_lang.js.map +1 -1
  223. package/lib/components/input-number/index.d.ts +5 -1
  224. package/lib/components/input-number/src/input-number.vue.d.ts +5 -1
  225. package/lib/components/input-number/src/input-number.vue_vue_type_script_lang.js +18 -4
  226. package/lib/components/input-number/src/input-number.vue_vue_type_script_lang.js.map +1 -1
  227. package/lib/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.js +5 -4
  228. package/lib/components/input-number/src/input-number.vue_vue_type_template_id_dec60af6_lang.js.map +1 -1
  229. package/lib/components/menu/src/menu-item.vue_vue_type_script_lang.js.map +1 -1
  230. package/lib/components/menu/src/menu-item.vue_vue_type_template_id_aa755baa_lang.js +2 -1
  231. package/lib/components/menu/src/menu-item.vue_vue_type_template_id_aa755baa_lang.js.map +1 -1
  232. package/lib/components/message/src/message-method.js +5 -1
  233. package/lib/components/message/src/message-method.js.map +1 -1
  234. package/lib/components/message/src/message.d.ts +3 -0
  235. package/lib/components/message/src/message.js.map +1 -1
  236. package/lib/components/message/src/message.vue.d.ts +2 -2
  237. package/lib/components/message-box/src/index.vue_vue_type_script_lang.js.map +1 -1
  238. package/lib/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.js +1 -0
  239. package/lib/components/message-box/src/index.vue_vue_type_template_id_7035e868_lang.js.map +1 -1
  240. package/lib/components/notification/src/notification.vue.d.ts +4 -4
  241. package/lib/components/popconfirm/src/popconfirm.vue_vue_type_script_lang.js.map +1 -1
  242. package/lib/components/popconfirm/src/popconfirm.vue_vue_type_template_id_16409d25_lang.js +2 -1
  243. package/lib/components/popconfirm/src/popconfirm.vue_vue_type_template_id_16409d25_lang.js.map +1 -1
  244. package/lib/components/popover/src/index.vue_vue_type_script_lang.js.map +1 -1
  245. package/lib/components/popover/src/index.vue_vue_type_template_id_15486cf0_lang.js +2 -1
  246. package/lib/components/popover/src/index.vue_vue_type_template_id_15486cf0_lang.js.map +1 -1
  247. package/lib/components/popper/src/content.vue_vue_type_script_lang.js.map +1 -1
  248. package/lib/components/popper/src/content.vue_vue_type_template_id_611b76f0_lang.js +1 -0
  249. package/lib/components/popper/src/content.vue_vue_type_template_id_611b76f0_lang.js.map +1 -1
  250. package/lib/components/radio/index.d.ts +6 -6
  251. package/lib/components/radio/index.js +2 -2
  252. package/lib/components/radio/src/radio-button.js +10 -5
  253. package/lib/components/radio/src/radio-button.js.map +1 -1
  254. package/lib/components/radio/src/radio-button.vue.d.ts +2 -2
  255. package/lib/components/radio/src/radio-button.vue_vue_type_script_lang.js +1 -1
  256. package/lib/components/radio/src/radio-button2.js +5 -10
  257. package/lib/components/radio/src/radio-button2.js.map +1 -1
  258. package/lib/components/radio/src/radio.vue.d.ts +2 -2
  259. package/lib/components/rate/index.d.ts +7 -1
  260. package/lib/components/rate/src/rate.d.ts +2 -0
  261. package/lib/components/rate/src/rate.js +5 -0
  262. package/lib/components/rate/src/rate.js.map +1 -1
  263. package/lib/components/rate/src/rate.vue.d.ts +7 -1
  264. package/lib/components/rate/src/rate.vue_vue_type_script_lang.js +6 -0
  265. package/lib/components/rate/src/rate.vue_vue_type_script_lang.js.map +1 -1
  266. package/lib/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.js +2 -2
  267. package/lib/components/rate/src/rate.vue_vue_type_template_id_38c42df6_lang.js.map +1 -1
  268. package/lib/components/select/index.d.ts +1 -1
  269. package/lib/components/select/src/select.vue.d.ts +1 -1
  270. package/lib/components/select/src/select.vue_vue_type_script_lang.js.map +1 -1
  271. package/lib/components/select/src/select.vue_vue_type_template_id_33774f85_lang.js +1 -0
  272. package/lib/components/select/src/select.vue_vue_type_template_id_33774f85_lang.js.map +1 -1
  273. package/lib/components/select-v2/index.d.ts +2 -2
  274. package/lib/components/select-v2/src/select.vue.d.ts +1 -1
  275. package/lib/components/select-v2/src/select.vue_vue_type_script_lang.js.map +1 -1
  276. package/lib/components/select-v2/src/select.vue_vue_type_template_id_13e598a4_lang.js +1 -0
  277. package/lib/components/select-v2/src/select.vue_vue_type_template_id_13e598a4_lang.js.map +1 -1
  278. package/lib/components/skeleton/index.js +2 -2
  279. package/lib/components/skeleton/src/skeleton.js +23 -5
  280. package/lib/components/skeleton/src/skeleton.js.map +1 -1
  281. package/lib/components/skeleton/src/skeleton.vue_vue_type_script_lang.js +1 -1
  282. package/lib/components/skeleton/src/skeleton2.js +5 -23
  283. package/lib/components/skeleton/src/skeleton2.js.map +1 -1
  284. package/lib/components/slider/index.d.ts +22 -6
  285. package/lib/components/slider/src/button.vue_vue_type_script_lang.js.map +1 -1
  286. package/lib/components/slider/src/button.vue_vue_type_template_id_9cd3e794_lang.js +2 -1
  287. package/lib/components/slider/src/button.vue_vue_type_template_id_9cd3e794_lang.js.map +1 -1
  288. package/lib/components/slider/src/index.vue.d.ts +11 -3
  289. package/lib/components/slider/src/index.vue_vue_type_script_lang.js +21 -2
  290. package/lib/components/slider/src/index.vue_vue_type_script_lang.js.map +1 -1
  291. package/lib/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.js +18 -18
  292. package/lib/components/slider/src/index.vue_vue_type_template_id_24c42d04_lang.js.map +1 -1
  293. package/lib/components/switch/index.d.ts +7 -2
  294. package/lib/components/switch/src/switch.d.ts +2 -0
  295. package/lib/components/switch/src/switch.js +5 -0
  296. package/lib/components/switch/src/switch.js.map +1 -1
  297. package/lib/components/switch/src/switch.vue.d.ts +7 -2
  298. package/lib/components/switch/src/switch.vue_vue_type_script_lang.js +9 -0
  299. package/lib/components/switch/src/switch.vue_vue_type_script_lang.js.map +1 -1
  300. package/lib/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.js +1 -1
  301. package/lib/components/switch/src/switch.vue_vue_type_template_id_538fbc85_lang.js.map +1 -1
  302. package/lib/components/table/src/filter-panel.vue_vue_type_script_lang.js.map +1 -1
  303. package/lib/components/table/src/filter-panel.vue_vue_type_template_id_fde1c940_lang.js +2 -1
  304. package/lib/components/table/src/filter-panel.vue_vue_type_template_id_fde1c940_lang.js.map +1 -1
  305. package/lib/components/table/src/table-layout.js +1 -2
  306. package/lib/components/table/src/table-layout.js.map +1 -1
  307. package/lib/components/table/src/util.d.ts +2 -2
  308. package/lib/components/table/src/util.js +9 -5
  309. package/lib/components/table/src/util.js.map +1 -1
  310. package/lib/components/tabs/index.d.ts +4 -4
  311. package/lib/components/tabs/src/tab-pane.vue.d.ts +2 -2
  312. package/lib/components/time-picker/index.d.ts +4 -4
  313. package/lib/components/time-picker/src/common/picker.vue.d.ts +2 -2
  314. package/lib/components/time-picker/src/common/picker.vue_vue_type_script_lang.js +6 -2
  315. package/lib/components/time-picker/src/common/picker.vue_vue_type_script_lang.js.map +1 -1
  316. package/lib/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.js +1 -0
  317. package/lib/components/time-picker/src/common/picker.vue_vue_type_template_id_1d54be91_lang.js.map +1 -1
  318. package/lib/components/time-picker/src/time-picker.d.ts +2 -2
  319. package/lib/components/transfer/src/transfer-panel.vue.d.ts +1 -2
  320. package/lib/components/transfer/src/transfer-panel.vue_vue_type_script_lang.js +3 -14
  321. package/lib/components/transfer/src/transfer-panel.vue_vue_type_script_lang.js.map +1 -1
  322. package/lib/components/transfer/src/transfer-panel.vue_vue_type_template_id_1a7d1f9c_lang.js +4 -17
  323. package/lib/components/transfer/src/transfer-panel.vue_vue_type_template_id_1a7d1f9c_lang.js.map +1 -1
  324. package/lib/defaults.d.ts +3 -1
  325. package/lib/hooks/index.js +1 -4
  326. package/lib/hooks/index.js.map +1 -1
  327. package/lib/hooks/use-global-config/index.d.ts +3 -1
  328. package/lib/hooks/use-global-config/index.js +3 -2
  329. package/lib/hooks/use-global-config/index.js.map +1 -1
  330. package/lib/hooks/use-id/index.js +2 -2
  331. package/lib/hooks/use-id/index.js.map +1 -1
  332. package/lib/hooks/use-locale/index.d.ts +2 -253
  333. package/lib/hooks/use-locale/index.js +8 -31
  334. package/lib/hooks/use-locale/index.js.map +1 -1
  335. package/lib/hooks/use-popper-container/index.js +2 -2
  336. package/lib/hooks/use-popper-container/index.js.map +1 -1
  337. package/lib/index.d.ts +4 -1
  338. package/lib/index.js +6 -6
  339. package/lib/index.js.map +1 -1
  340. package/lib/version.d.ts +1 -1
  341. package/lib/version.js +1 -1
  342. package/lib/version.js.map +1 -1
  343. package/package.json +2 -2
  344. package/tags.json +1 -1
  345. package/theme-chalk/el-cascader.css +1 -1
  346. package/theme-chalk/el-checkbox.css +1 -1
  347. package/theme-chalk/el-date-picker.css +1 -1
  348. package/theme-chalk/el-form.css +1 -1
  349. package/theme-chalk/el-pagination.css +1 -1
  350. package/theme-chalk/el-radio.css +1 -1
  351. package/theme-chalk/el-rate.css +1 -1
  352. package/theme-chalk/el-select-v2.css +1 -1
  353. package/theme-chalk/el-slider.css +1 -1
  354. package/theme-chalk/el-switch.css +1 -1
  355. package/theme-chalk/el-tag.css +1 -1
  356. package/theme-chalk/el-time-picker.css +1 -1
  357. package/theme-chalk/el-time-select.css +1 -1
  358. package/theme-chalk/el-transfer.css +1 -1
  359. package/theme-chalk/index.css +1 -1
  360. package/theme-chalk/src/cascader.scss +4 -0
  361. package/theme-chalk/src/checkbox.scss +40 -6
  362. package/theme-chalk/src/common/var.scss +2 -4
  363. package/theme-chalk/src/date-picker/picker-panel.scss +1 -1
  364. package/theme-chalk/src/date-picker/picker.scss +1 -0
  365. package/theme-chalk/src/form.scss +101 -24
  366. package/theme-chalk/src/pagination.scss +0 -3
  367. package/theme-chalk/src/radio.scss +21 -0
  368. package/theme-chalk/src/rate.scss +19 -2
  369. package/theme-chalk/src/select-v2.scss +2 -3
  370. package/theme-chalk/src/slider.scss +28 -77
  371. package/theme-chalk/src/switch.scss +43 -4
  372. package/theme-chalk/src/tag.scss +3 -3
  373. package/theme-chalk/src/transfer.scss +27 -31
  374. package/web-types.json +1 -1
  375. package/es/utils/isServer.d.ts +0 -2
  376. package/es/utils/isServer.mjs +0 -4
  377. package/es/utils/isServer.mjs.map +0 -1
  378. package/lib/utils/isServer.d.ts +0 -2
  379. package/lib/utils/isServer.js +0 -8
  380. package/lib/utils/isServer.js.map +0 -1
@@ -3,6 +3,8 @@ import { ElInputNumber } from '../../input-number/index.mjs';
3
3
  import { UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT } from '../../../utils/constants.mjs';
4
4
  import { on, off } from '../../../utils/dom.mjs';
5
5
  import { throwError } from '../../../utils/error.mjs';
6
+ import { isValidComponentSize } from '../../../utils/validators.mjs';
7
+ import '../../../hooks/index.mjs';
6
8
  import './button.mjs';
7
9
  import './marker.mjs';
8
10
  import { useMarks } from './useMarks.mjs';
@@ -10,6 +12,7 @@ import { useSlide } from './useSlide.mjs';
10
12
  import { useStops } from './useStops.mjs';
11
13
  import script$1 from './button.vue_vue_type_script_lang.mjs';
12
14
  import script$2 from './marker.vue_vue_type_script_lang.mjs';
15
+ import { useSize } from '../../../hooks/use-common-props/index.mjs';
13
16
 
14
17
  var script = defineComponent({
15
18
  name: "ElSlider",
@@ -43,9 +46,13 @@ var script = defineComponent({
43
46
  type: Boolean,
44
47
  default: true
45
48
  },
49
+ size: {
50
+ type: String,
51
+ validator: isValidComponentSize
52
+ },
46
53
  inputSize: {
47
54
  type: String,
48
- default: "small"
55
+ validator: isValidComponentSize
49
56
  },
50
57
  showStops: {
51
58
  type: Boolean,
@@ -115,6 +122,15 @@ var script = defineComponent({
115
122
  setSecondValue
116
123
  } = useSlide(props, initData, emit);
117
124
  const { stops, getStopStyle } = useStops(props, initData, minValue, maxValue);
125
+ const sliderWrapperSize = useSize();
126
+ const sliderInputSize = computed(() => props.inputSize || sliderWrapperSize.value);
127
+ const prefix = "el-slider";
128
+ const sliderKls = computed(() => [
129
+ prefix,
130
+ `${prefix}--${sliderWrapperSize.value}`,
131
+ props.vertical ? "is-vertical" : "",
132
+ props.showInput ? "el-slider--with-input" : ""
133
+ ]);
118
134
  const markList = useMarks(props);
119
135
  useWatch(props, initData, minValue, maxValue, emit, elFormItem);
120
136
  const precision = computed(() => {
@@ -157,7 +173,10 @@ var script = defineComponent({
157
173
  setSecondValue,
158
174
  stops,
159
175
  markList,
160
- sliderWrapper
176
+ sliderWrapper,
177
+ sliderWrapperSize,
178
+ sliderInputSize,
179
+ sliderKls
161
180
  };
162
181
  }
163
182
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/slider/src/index.vue"],"sourcesContent":["<template>\n <div\n ref=\"sliderWrapper\"\n class=\"el-slider\"\n :class=\"{ 'is-vertical': vertical, 'el-slider--with-input': showInput }\"\n role=\"slider\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n :aria-disabled=\"sliderDisabled\"\n >\n <el-input-number\n v-if=\"showInput && !range\"\n ref=\"input\"\n :model-value=\"firstValue\"\n class=\"el-slider__input\"\n :step=\"step\"\n :disabled=\"sliderDisabled\"\n :controls=\"showInputControls\"\n :min=\"min\"\n :max=\"max\"\n :debounce=\"debounce\"\n :size=\"inputSize\"\n @update:model-value=\"setFirstValue\"\n @change=\"emitChange\"\n />\n <div\n ref=\"slider\"\n class=\"el-slider__runway\"\n :class=\"{ 'show-input': showInput && !range, disabled: sliderDisabled }\"\n :style=\"runwayStyle\"\n @click=\"onSliderClick\"\n >\n <div class=\"el-slider__bar\" :style=\"barStyle\"></div>\n <slider-button\n ref=\"firstButton\"\n :model-value=\"firstValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setFirstValue\"\n />\n <slider-button\n v-if=\"range\"\n ref=\"secondButton\"\n :model-value=\"secondValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setSecondValue\"\n />\n <div v-if=\"showStops\">\n <div\n v-for=\"(item, key) in stops\"\n :key=\"key\"\n class=\"el-slider__stop\"\n :style=\"getStopStyle(item)\"\n ></div>\n </div>\n <template v-if=\"markList.length > 0\">\n <div>\n <div\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :style=\"getStopStyle(item.position)\"\n class=\"el-slider__stop el-slider__marks-stop\"\n ></div>\n </div>\n <div class=\"el-slider__marks\">\n <slider-marker\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :mark=\"item.mark\"\n :style=\"getStopStyle(item.position)\"\n />\n </div>\n </template>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n reactive,\n ref,\n toRefs,\n watch,\n} from 'vue'\nimport ElInputNumber from '@element-plus/components/input-number'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { off, on } from '@element-plus/utils/dom'\nimport { throwError } from '@element-plus/utils/error'\nimport SliderButton from './button.vue'\nimport SliderMarker from './marker.vue'\nimport { useMarks } from './useMarks'\nimport { useSlide } from './useSlide'\nimport { useStops } from './useStops'\n\nimport type { PropType, Ref } from 'vue'\nimport type { ComponentSize, Nullable } from '@element-plus/utils/types'\n\nexport default defineComponent({\n name: 'ElSlider',\n\n components: {\n ElInputNumber,\n SliderButton,\n SliderMarker,\n },\n\n props: {\n modelValue: {\n type: [Number, Array] as PropType<number | number[]>,\n default: 0,\n },\n min: {\n type: Number,\n default: 0,\n },\n max: {\n type: Number,\n default: 100,\n },\n step: {\n type: Number,\n default: 1,\n },\n showInput: {\n type: Boolean,\n default: false,\n },\n showInputControls: {\n type: Boolean,\n default: true,\n },\n inputSize: {\n type: String as PropType<ComponentSize>,\n default: 'small',\n },\n showStops: {\n type: Boolean,\n default: false,\n },\n showTooltip: {\n type: Boolean,\n default: true,\n },\n formatTooltip: {\n type: Function as PropType<(val: number) => number | string>,\n default: undefined,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n range: {\n type: Boolean,\n default: false,\n },\n vertical: {\n type: Boolean,\n default: false,\n },\n height: {\n type: String,\n default: '',\n },\n debounce: {\n type: Number,\n default: 300,\n },\n label: {\n type: String,\n default: undefined,\n },\n tooltipClass: {\n type: String,\n default: undefined,\n },\n marks: Object,\n },\n\n emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT],\n\n setup(props, { emit }) {\n const initData = reactive({\n firstValue: 0,\n secondValue: 0,\n oldValue: 0,\n dragging: false,\n sliderSize: 1,\n })\n\n const {\n elFormItem,\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n minValue,\n maxValue,\n runwayStyle,\n barStyle,\n resetSize,\n emitChange,\n onSliderClick,\n setFirstValue,\n setSecondValue,\n } = useSlide(props, initData, emit)\n\n const { stops, getStopStyle } = useStops(\n props,\n initData,\n minValue,\n maxValue\n )\n\n const markList = useMarks(props)\n\n useWatch(props, initData, minValue, maxValue, emit, elFormItem)\n\n const precision = computed(() => {\n const precisions = [props.min, props.max, props.step].map((item) => {\n const decimal = `${item}`.split('.')[1]\n return decimal ? decimal.length : 0\n })\n return Math.max.apply(null, precisions)\n })\n\n const { sliderWrapper } = useLifecycle(props, initData, resetSize)\n\n const { firstValue, secondValue, oldValue, dragging, sliderSize } =\n toRefs(initData)\n\n const updateDragging = (val: boolean) => {\n initData.dragging = val\n }\n\n provide('SliderProvider', {\n ...toRefs(props),\n sliderSize,\n disabled: sliderDisabled,\n precision,\n emitChange,\n resetSize,\n updateDragging,\n })\n\n return {\n firstValue,\n secondValue,\n oldValue,\n dragging,\n sliderSize,\n\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n runwayStyle,\n barStyle,\n emitChange,\n onSliderClick,\n getStopStyle,\n setFirstValue,\n setSecondValue,\n\n stops,\n markList,\n\n sliderWrapper,\n }\n },\n})\n\nconst useWatch = (props, initData, minValue, maxValue, emit, elFormItem) => {\n const _emit = (val: number | number[]) => {\n emit(UPDATE_MODEL_EVENT, val)\n emit(INPUT_EVENT, val)\n }\n\n const valueChanged = () => {\n if (props.range) {\n return ![minValue.value, maxValue.value].every(\n (item, index) => item === initData.oldValue[index]\n )\n } else {\n return props.modelValue !== initData.oldValue\n }\n }\n\n const setValues = () => {\n if (props.min > props.max) {\n throwError('Slider', 'min should not be greater than max.')\n return\n }\n const val = props.modelValue\n if (props.range && Array.isArray(val)) {\n if (val[1] < props.min) {\n _emit([props.min, props.min])\n } else if (val[0] > props.max) {\n _emit([props.max, props.max])\n } else if (val[0] < props.min) {\n _emit([props.min, val[1]])\n } else if (val[1] > props.max) {\n _emit([val[0], props.max])\n } else {\n initData.firstValue = val[0]\n initData.secondValue = val[1]\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val.slice()\n }\n }\n } else if (!props.range && typeof val === 'number' && !isNaN(val)) {\n if (val < props.min) {\n _emit(props.min)\n } else if (val > props.max) {\n _emit(props.max)\n } else {\n initData.firstValue = val\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val\n }\n }\n }\n }\n\n setValues()\n\n watch(\n () => initData.dragging,\n (val) => {\n if (!val) {\n setValues()\n }\n }\n )\n\n watch(\n () => props.modelValue,\n (val, oldVal) => {\n if (\n initData.dragging ||\n (Array.isArray(val) &&\n Array.isArray(oldVal) &&\n val.every((item, index) => item === oldVal[index]))\n ) {\n return\n }\n setValues()\n }\n )\n\n watch(\n () => [props.min, props.max],\n () => {\n setValues()\n }\n )\n}\n\nconst useLifecycle = (props, initData, resetSize) => {\n const sliderWrapper: Ref<Nullable<HTMLElement>> = ref(null)\n\n onMounted(async () => {\n let valuetext\n if (props.range) {\n if (Array.isArray(props.modelValue)) {\n initData.firstValue = Math.max(props.min, props.modelValue[0])\n initData.secondValue = Math.min(props.max, props.modelValue[1])\n } else {\n initData.firstValue = props.min\n initData.secondValue = props.max\n }\n initData.oldValue = [initData.firstValue, initData.secondValue]\n valuetext = `${initData.firstValue}-${initData.secondValue}`\n } else {\n if (typeof props.modelValue !== 'number' || isNaN(props.modelValue)) {\n initData.firstValue = props.min\n } else {\n initData.firstValue = Math.min(\n props.max,\n Math.max(props.min, props.modelValue)\n )\n }\n initData.oldValue = initData.firstValue\n valuetext = initData.firstValue\n }\n\n sliderWrapper.value.setAttribute('aria-valuetext', valuetext)\n\n // label screen reader\n sliderWrapper.value.setAttribute(\n 'aria-label',\n props.label ? props.label : `slider between ${props.min} and ${props.max}`\n )\n\n on(window, 'resize', resetSize)\n\n await nextTick()\n resetSize()\n })\n\n onBeforeUnmount(() => {\n off(window, 'resize', resetSize)\n })\n\n return {\n sliderWrapper,\n }\n}\n</script>\n"],"names":["SliderMarker"],"mappings":";;;;;;;;;;;;;AAwGA,aAAe,eAAe,CAAC;;AAE/B,EAAE,UAAU,EAAE;AACd,IAAI,aAAa;;AAEjB,kBAAIA,QAAY;GACb;;IAEC,UAAU;MACR,IAAI,EAAE,CAAC;MACP,OAAO,EAAE,CAAC;KACX;;;MAGC;KACD;OACE,EAAE;MACH,IAAI,EAAE;;KAEP;QACG,EAAE;MACJ,IAAI,EAAE;;KAEP;aACQ,EAAE;MACT,IAAI,EAAE;;KAEP;;MAEC,IAAI,EAAE;;KAEP;aACQ,EAAE;MACT,IAAI,EAAE,MAAM;;KAEb;aACQ,EAAE;MACT,IAAI,EAAE,OAAO;;KAEd;eACU,EAAE;MACX,IAAI,EAAE,OAAO;;KAEd;iBACY,EAAE;MACb,IAAI,EAAE,QAAQ;;KAEf;YACO,EAAE;MACR,IAAI,EAAE,OAAO;;KAEd;SACI;MACH,IAAI,EAAE,OAAO;;KAEd;YACO,EAAE;MACR,IAAI,EAAE,OAAO;;KAEd;UACK,EAAE;MACN,IAAI,EAAE,MAAM;;KAEb;YACO,EAAE;MACR,IAAI,EAAE,MAAM;;KAEb;SACI;MACH,IAAI,EAAE;;KAEP;gBACW,EAAE;MACZ,IAAI,EAAE,MAAM;;KAEb;SACI,QAAQ;;;OAGV,CAAC,KAAK,EAAE;UACL,QAAQ;MACZ,UAAU,EAAE,CAAC;;MAEb,QAAQ,EAAE,CAAC;;;KAGZ,CAAC,CAAC;;MAED;MACA,MAAM;MACN;MACA;MACA;MACA,QAAQ;MACR,QAAQ;;;MAGR;MACA,UAAU;MACV;MACA;MACA;QACE,QAAQ,CAAC;UACP,EAAE;UACF;YACE,CAAC;UACH;MACJ,MAAM;QACJ,MAAM;QACN,OAAO;OACR,CAAC,CAAC;MACH,OAAO,IAAI,CAAC;MACZ;;IAEF,MAAM,EAAE,UAAU,EAAE,aAAa;UAC3B;MACJ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T;aACK;QACL,QAAQ,CAAC;gBACD,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG;;;MAGlC;;;;OAIC;;OAEA;cACO,CAAC,QAAQ,GAAG;MACpB;;iBAEW,CAAC;;IAEd;;;GAGD,CAAC,CAAC;iBACY,CAAC,MAAM;IACpB,GAAG,CAAC,MAAM,EAAE;;SAEP;iBACQ;;;;;;"}
1
+ {"version":3,"file":"index.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/slider/src/index.vue"],"sourcesContent":["<template>\n <div\n ref=\"sliderWrapper\"\n :class=\"sliderKls\"\n role=\"slider\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n :aria-disabled=\"sliderDisabled\"\n >\n <div\n ref=\"slider\"\n class=\"el-slider__runway\"\n :class=\"{ 'show-input': showInput && !range, disabled: sliderDisabled }\"\n :style=\"runwayStyle\"\n @click=\"onSliderClick\"\n >\n <div class=\"el-slider__bar\" :style=\"barStyle\"></div>\n <slider-button\n ref=\"firstButton\"\n :model-value=\"firstValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setFirstValue\"\n />\n <slider-button\n v-if=\"range\"\n ref=\"secondButton\"\n :model-value=\"secondValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setSecondValue\"\n />\n <div v-if=\"showStops\">\n <div\n v-for=\"(item, key) in stops\"\n :key=\"key\"\n class=\"el-slider__stop\"\n :style=\"getStopStyle(item)\"\n ></div>\n </div>\n <template v-if=\"markList.length > 0\">\n <div>\n <div\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :style=\"getStopStyle(item.position)\"\n class=\"el-slider__stop el-slider__marks-stop\"\n ></div>\n </div>\n <div class=\"el-slider__marks\">\n <slider-marker\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :mark=\"item.mark\"\n :style=\"getStopStyle(item.position)\"\n />\n </div>\n </template>\n </div>\n <el-input-number\n v-if=\"showInput && !range\"\n ref=\"input\"\n :model-value=\"firstValue\"\n class=\"el-slider__input\"\n :step=\"step\"\n :disabled=\"sliderDisabled\"\n :controls=\"showInputControls\"\n :min=\"min\"\n :max=\"max\"\n :debounce=\"debounce\"\n :size=\"sliderInputSize\"\n @update:model-value=\"setFirstValue\"\n @change=\"emitChange\"\n />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n reactive,\n ref,\n toRefs,\n watch,\n} from 'vue'\nimport ElInputNumber from '@element-plus/components/input-number'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { off, on } from '@element-plus/utils/dom'\nimport { throwError } from '@element-plus/utils/error'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport { useSize } from '@element-plus/hooks'\nimport SliderButton from './button.vue'\nimport SliderMarker from './marker.vue'\nimport { useMarks } from './useMarks'\nimport { useSlide } from './useSlide'\nimport { useStops } from './useStops'\n\nimport type { PropType, Ref } from 'vue'\nimport type { ComponentSize, Nullable } from '@element-plus/utils/types'\n\nexport default defineComponent({\n name: 'ElSlider',\n\n components: {\n ElInputNumber,\n SliderButton,\n SliderMarker,\n },\n\n props: {\n modelValue: {\n type: [Number, Array] as PropType<number | number[]>,\n default: 0,\n },\n min: {\n type: Number,\n default: 0,\n },\n max: {\n type: Number,\n default: 100,\n },\n step: {\n type: Number,\n default: 1,\n },\n showInput: {\n type: Boolean,\n default: false,\n },\n showInputControls: {\n type: Boolean,\n default: true,\n },\n size: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n inputSize: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n showStops: {\n type: Boolean,\n default: false,\n },\n showTooltip: {\n type: Boolean,\n default: true,\n },\n formatTooltip: {\n type: Function as PropType<(val: number) => number | string>,\n default: undefined,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n range: {\n type: Boolean,\n default: false,\n },\n vertical: {\n type: Boolean,\n default: false,\n },\n height: {\n type: String,\n default: '',\n },\n debounce: {\n type: Number,\n default: 300,\n },\n label: {\n type: String,\n default: undefined,\n },\n tooltipClass: {\n type: String,\n default: undefined,\n },\n marks: Object,\n },\n\n emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT],\n\n setup(props, { emit }) {\n const initData = reactive({\n firstValue: 0,\n secondValue: 0,\n oldValue: 0,\n dragging: false,\n sliderSize: 1,\n })\n\n const {\n elFormItem,\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n minValue,\n maxValue,\n runwayStyle,\n barStyle,\n resetSize,\n emitChange,\n onSliderClick,\n setFirstValue,\n setSecondValue,\n } = useSlide(props, initData, emit)\n\n const { stops, getStopStyle } = useStops(\n props,\n initData,\n minValue,\n maxValue\n )\n\n const sliderWrapperSize = useSize()\n const sliderInputSize = computed(\n () => props.inputSize || sliderWrapperSize.value\n )\n\n const prefix = 'el-slider'\n const sliderKls = computed(() => [\n prefix,\n `${prefix}--${sliderWrapperSize.value}`,\n props.vertical ? 'is-vertical' : '',\n props.showInput ? 'el-slider--with-input' : '',\n ])\n\n const markList = useMarks(props)\n\n useWatch(props, initData, minValue, maxValue, emit, elFormItem)\n\n const precision = computed(() => {\n const precisions = [props.min, props.max, props.step].map((item) => {\n const decimal = `${item}`.split('.')[1]\n return decimal ? decimal.length : 0\n })\n return Math.max.apply(null, precisions)\n })\n\n const { sliderWrapper } = useLifecycle(props, initData, resetSize)\n\n const { firstValue, secondValue, oldValue, dragging, sliderSize } =\n toRefs(initData)\n\n const updateDragging = (val: boolean) => {\n initData.dragging = val\n }\n\n provide('SliderProvider', {\n ...toRefs(props),\n sliderSize,\n disabled: sliderDisabled,\n precision,\n emitChange,\n resetSize,\n updateDragging,\n })\n\n return {\n firstValue,\n secondValue,\n oldValue,\n dragging,\n sliderSize,\n\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n runwayStyle,\n barStyle,\n emitChange,\n onSliderClick,\n getStopStyle,\n setFirstValue,\n setSecondValue,\n\n stops,\n markList,\n\n sliderWrapper,\n sliderWrapperSize,\n sliderInputSize,\n sliderKls,\n }\n },\n})\n\nconst useWatch = (props, initData, minValue, maxValue, emit, elFormItem) => {\n const _emit = (val: number | number[]) => {\n emit(UPDATE_MODEL_EVENT, val)\n emit(INPUT_EVENT, val)\n }\n\n const valueChanged = () => {\n if (props.range) {\n return ![minValue.value, maxValue.value].every(\n (item, index) => item === initData.oldValue[index]\n )\n } else {\n return props.modelValue !== initData.oldValue\n }\n }\n\n const setValues = () => {\n if (props.min > props.max) {\n throwError('Slider', 'min should not be greater than max.')\n return\n }\n const val = props.modelValue\n if (props.range && Array.isArray(val)) {\n if (val[1] < props.min) {\n _emit([props.min, props.min])\n } else if (val[0] > props.max) {\n _emit([props.max, props.max])\n } else if (val[0] < props.min) {\n _emit([props.min, val[1]])\n } else if (val[1] > props.max) {\n _emit([val[0], props.max])\n } else {\n initData.firstValue = val[0]\n initData.secondValue = val[1]\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val.slice()\n }\n }\n } else if (!props.range && typeof val === 'number' && !isNaN(val)) {\n if (val < props.min) {\n _emit(props.min)\n } else if (val > props.max) {\n _emit(props.max)\n } else {\n initData.firstValue = val\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val\n }\n }\n }\n }\n\n setValues()\n\n watch(\n () => initData.dragging,\n (val) => {\n if (!val) {\n setValues()\n }\n }\n )\n\n watch(\n () => props.modelValue,\n (val, oldVal) => {\n if (\n initData.dragging ||\n (Array.isArray(val) &&\n Array.isArray(oldVal) &&\n val.every((item, index) => item === oldVal[index]))\n ) {\n return\n }\n setValues()\n }\n )\n\n watch(\n () => [props.min, props.max],\n () => {\n setValues()\n }\n )\n}\n\nconst useLifecycle = (props, initData, resetSize) => {\n const sliderWrapper: Ref<Nullable<HTMLElement>> = ref(null)\n\n onMounted(async () => {\n let valuetext\n if (props.range) {\n if (Array.isArray(props.modelValue)) {\n initData.firstValue = Math.max(props.min, props.modelValue[0])\n initData.secondValue = Math.min(props.max, props.modelValue[1])\n } else {\n initData.firstValue = props.min\n initData.secondValue = props.max\n }\n initData.oldValue = [initData.firstValue, initData.secondValue]\n valuetext = `${initData.firstValue}-${initData.secondValue}`\n } else {\n if (typeof props.modelValue !== 'number' || isNaN(props.modelValue)) {\n initData.firstValue = props.min\n } else {\n initData.firstValue = Math.min(\n props.max,\n Math.max(props.min, props.modelValue)\n )\n }\n initData.oldValue = initData.firstValue\n valuetext = initData.firstValue\n }\n\n sliderWrapper.value.setAttribute('aria-valuetext', valuetext)\n\n // label screen reader\n sliderWrapper.value.setAttribute(\n 'aria-label',\n props.label ? props.label : `slider between ${props.min} and ${props.max}`\n )\n\n on(window, 'resize', resetSize)\n\n await nextTick()\n resetSize()\n })\n\n onBeforeUnmount(() => {\n off(window, 'resize', resetSize)\n })\n\n return {\n sliderWrapper,\n }\n}\n</script>\n"],"names":["SliderMarker"],"mappings":";;;;;;;;;;;;;;;;AAyGA,aAAe,eAAe,CAAC;;AAE/B,EAAE,UAAU,EAAE;AACd,IAAI,aAAa;;AAEjB,kBAAIA,QAAY;GACb;;IAEC,UAAU;MACR,IAAI,EAAE,CAAC;MACP,OAAO,EAAE,CAAC;KACX;;;MAGC;KACD;OACE,EAAE;MACH,IAAI,EAAE;;KAEP;QACG,EAAE;MACJ,IAAI,EAAE;;KAEP;aACQ,EAAE;MACT,IAAI,EAAE;;KAEP;;MAEC,IAAI,EAAE;;KAEP;QACG,EAAE;MACJ,IAAI,EAAE,MAAM;;KAEb;aACQ,EAAE;MACT,IAAI,EAAE,MAAM;;KAEb;aACQ,EAAE;MACT,IAAI,EAAE,OAAO;;KAEd;eACU,EAAE;MACX,IAAI,EAAE,OAAO;;KAEd;iBACY,EAAE;MACb,IAAI,EAAE,QAAQ;;KAEf;YACO,EAAE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;EAKd;IACE,aAAa;IACb;;;;;"}
@@ -1,36 +1,21 @@
1
- import { resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, createCommentVNode, createElementVNode, normalizeStyle, createVNode, Fragment, renderList } from 'vue';
1
+ import { resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, createVNode, createBlock, createCommentVNode, Fragment, renderList } from 'vue';
2
2
 
3
3
  const _hoisted_1 = ["aria-valuemin", "aria-valuemax", "aria-orientation", "aria-disabled"];
4
4
  const _hoisted_2 = { key: 1 };
5
5
  const _hoisted_3 = { class: "el-slider__marks" };
6
6
  function render(_ctx, _cache, $props, $setup, $data, $options) {
7
- const _component_el_input_number = resolveComponent("el-input-number");
8
7
  const _component_slider_button = resolveComponent("slider-button");
9
8
  const _component_slider_marker = resolveComponent("slider-marker");
9
+ const _component_el_input_number = resolveComponent("el-input-number");
10
10
  return openBlock(), createElementBlock("div", {
11
11
  ref: "sliderWrapper",
12
- class: normalizeClass(["el-slider", { "is-vertical": _ctx.vertical, "el-slider--with-input": _ctx.showInput }]),
12
+ class: normalizeClass(_ctx.sliderKls),
13
13
  role: "slider",
14
14
  "aria-valuemin": _ctx.min,
15
15
  "aria-valuemax": _ctx.max,
16
16
  "aria-orientation": _ctx.vertical ? "vertical" : "horizontal",
17
17
  "aria-disabled": _ctx.sliderDisabled
18
18
  }, [
19
- _ctx.showInput && !_ctx.range ? (openBlock(), createBlock(_component_el_input_number, {
20
- key: 0,
21
- ref: "input",
22
- "model-value": _ctx.firstValue,
23
- class: "el-slider__input",
24
- step: _ctx.step,
25
- disabled: _ctx.sliderDisabled,
26
- controls: _ctx.showInputControls,
27
- min: _ctx.min,
28
- max: _ctx.max,
29
- debounce: _ctx.debounce,
30
- size: _ctx.inputSize,
31
- "onUpdate:modelValue": _ctx.setFirstValue,
32
- onChange: _ctx.emitChange
33
- }, null, 8, ["model-value", "step", "disabled", "controls", "min", "max", "debounce", "size", "onUpdate:modelValue", "onChange"])) : createCommentVNode("v-if", true),
34
19
  createElementVNode("div", {
35
20
  ref: "slider",
36
21
  class: normalizeClass(["el-slider__runway", { "show-input": _ctx.showInput && !_ctx.range, disabled: _ctx.sliderDisabled }]),
@@ -85,7 +70,22 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
85
70
  }), 128))
86
71
  ])
87
72
  ], 64)) : createCommentVNode("v-if", true)
88
- ], 6)
73
+ ], 6),
74
+ _ctx.showInput && !_ctx.range ? (openBlock(), createBlock(_component_el_input_number, {
75
+ key: 0,
76
+ ref: "input",
77
+ "model-value": _ctx.firstValue,
78
+ class: "el-slider__input",
79
+ step: _ctx.step,
80
+ disabled: _ctx.sliderDisabled,
81
+ controls: _ctx.showInputControls,
82
+ min: _ctx.min,
83
+ max: _ctx.max,
84
+ debounce: _ctx.debounce,
85
+ size: _ctx.sliderInputSize,
86
+ "onUpdate:modelValue": _ctx.setFirstValue,
87
+ onChange: _ctx.emitChange
88
+ }, null, 8, ["model-value", "step", "disabled", "controls", "min", "max", "debounce", "size", "onUpdate:modelValue", "onChange"])) : createCommentVNode("v-if", true)
89
89
  ], 10, _hoisted_1);
90
90
  }
91
91
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.vue_vue_type_template_id_24c42d04_lang.mjs","sources":["../../../../../../packages/components/slider/src/index.vue?vue&type=template&id=24c42d04&lang.js"],"sourcesContent":["<template>\n <div\n ref=\"sliderWrapper\"\n class=\"el-slider\"\n :class=\"{ 'is-vertical': vertical, 'el-slider--with-input': showInput }\"\n role=\"slider\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n :aria-disabled=\"sliderDisabled\"\n >\n <el-input-number\n v-if=\"showInput && !range\"\n ref=\"input\"\n :model-value=\"firstValue\"\n class=\"el-slider__input\"\n :step=\"step\"\n :disabled=\"sliderDisabled\"\n :controls=\"showInputControls\"\n :min=\"min\"\n :max=\"max\"\n :debounce=\"debounce\"\n :size=\"inputSize\"\n @update:model-value=\"setFirstValue\"\n @change=\"emitChange\"\n />\n <div\n ref=\"slider\"\n class=\"el-slider__runway\"\n :class=\"{ 'show-input': showInput && !range, disabled: sliderDisabled }\"\n :style=\"runwayStyle\"\n @click=\"onSliderClick\"\n >\n <div class=\"el-slider__bar\" :style=\"barStyle\"></div>\n <slider-button\n ref=\"firstButton\"\n :model-value=\"firstValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setFirstValue\"\n />\n <slider-button\n v-if=\"range\"\n ref=\"secondButton\"\n :model-value=\"secondValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setSecondValue\"\n />\n <div v-if=\"showStops\">\n <div\n v-for=\"(item, key) in stops\"\n :key=\"key\"\n class=\"el-slider__stop\"\n :style=\"getStopStyle(item)\"\n ></div>\n </div>\n <template v-if=\"markList.length > 0\">\n <div>\n <div\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :style=\"getStopStyle(item.position)\"\n class=\"el-slider__stop el-slider__marks-stop\"\n ></div>\n </div>\n <div class=\"el-slider__marks\">\n <slider-marker\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :mark=\"item.mark\"\n :style=\"getStopStyle(item.position)\"\n />\n </div>\n </template>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n reactive,\n ref,\n toRefs,\n watch,\n} from 'vue'\nimport ElInputNumber from '@element-plus/components/input-number'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { off, on } from '@element-plus/utils/dom'\nimport { throwError } from '@element-plus/utils/error'\nimport SliderButton from './button.vue'\nimport SliderMarker from './marker.vue'\nimport { useMarks } from './useMarks'\nimport { useSlide } from './useSlide'\nimport { useStops } from './useStops'\n\nimport type { PropType, Ref } from 'vue'\nimport type { ComponentSize, Nullable } from '@element-plus/utils/types'\n\nexport default defineComponent({\n name: 'ElSlider',\n\n components: {\n ElInputNumber,\n SliderButton,\n SliderMarker,\n },\n\n props: {\n modelValue: {\n type: [Number, Array] as PropType<number | number[]>,\n default: 0,\n },\n min: {\n type: Number,\n default: 0,\n },\n max: {\n type: Number,\n default: 100,\n },\n step: {\n type: Number,\n default: 1,\n },\n showInput: {\n type: Boolean,\n default: false,\n },\n showInputControls: {\n type: Boolean,\n default: true,\n },\n inputSize: {\n type: String as PropType<ComponentSize>,\n default: 'small',\n },\n showStops: {\n type: Boolean,\n default: false,\n },\n showTooltip: {\n type: Boolean,\n default: true,\n },\n formatTooltip: {\n type: Function as PropType<(val: number) => number | string>,\n default: undefined,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n range: {\n type: Boolean,\n default: false,\n },\n vertical: {\n type: Boolean,\n default: false,\n },\n height: {\n type: String,\n default: '',\n },\n debounce: {\n type: Number,\n default: 300,\n },\n label: {\n type: String,\n default: undefined,\n },\n tooltipClass: {\n type: String,\n default: undefined,\n },\n marks: Object,\n },\n\n emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT],\n\n setup(props, { emit }) {\n const initData = reactive({\n firstValue: 0,\n secondValue: 0,\n oldValue: 0,\n dragging: false,\n sliderSize: 1,\n })\n\n const {\n elFormItem,\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n minValue,\n maxValue,\n runwayStyle,\n barStyle,\n resetSize,\n emitChange,\n onSliderClick,\n setFirstValue,\n setSecondValue,\n } = useSlide(props, initData, emit)\n\n const { stops, getStopStyle } = useStops(\n props,\n initData,\n minValue,\n maxValue\n )\n\n const markList = useMarks(props)\n\n useWatch(props, initData, minValue, maxValue, emit, elFormItem)\n\n const precision = computed(() => {\n const precisions = [props.min, props.max, props.step].map((item) => {\n const decimal = `${item}`.split('.')[1]\n return decimal ? decimal.length : 0\n })\n return Math.max.apply(null, precisions)\n })\n\n const { sliderWrapper } = useLifecycle(props, initData, resetSize)\n\n const { firstValue, secondValue, oldValue, dragging, sliderSize } =\n toRefs(initData)\n\n const updateDragging = (val: boolean) => {\n initData.dragging = val\n }\n\n provide('SliderProvider', {\n ...toRefs(props),\n sliderSize,\n disabled: sliderDisabled,\n precision,\n emitChange,\n resetSize,\n updateDragging,\n })\n\n return {\n firstValue,\n secondValue,\n oldValue,\n dragging,\n sliderSize,\n\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n runwayStyle,\n barStyle,\n emitChange,\n onSliderClick,\n getStopStyle,\n setFirstValue,\n setSecondValue,\n\n stops,\n markList,\n\n sliderWrapper,\n }\n },\n})\n\nconst useWatch = (props, initData, minValue, maxValue, emit, elFormItem) => {\n const _emit = (val: number | number[]) => {\n emit(UPDATE_MODEL_EVENT, val)\n emit(INPUT_EVENT, val)\n }\n\n const valueChanged = () => {\n if (props.range) {\n return ![minValue.value, maxValue.value].every(\n (item, index) => item === initData.oldValue[index]\n )\n } else {\n return props.modelValue !== initData.oldValue\n }\n }\n\n const setValues = () => {\n if (props.min > props.max) {\n throwError('Slider', 'min should not be greater than max.')\n return\n }\n const val = props.modelValue\n if (props.range && Array.isArray(val)) {\n if (val[1] < props.min) {\n _emit([props.min, props.min])\n } else if (val[0] > props.max) {\n _emit([props.max, props.max])\n } else if (val[0] < props.min) {\n _emit([props.min, val[1]])\n } else if (val[1] > props.max) {\n _emit([val[0], props.max])\n } else {\n initData.firstValue = val[0]\n initData.secondValue = val[1]\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val.slice()\n }\n }\n } else if (!props.range && typeof val === 'number' && !isNaN(val)) {\n if (val < props.min) {\n _emit(props.min)\n } else if (val > props.max) {\n _emit(props.max)\n } else {\n initData.firstValue = val\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val\n }\n }\n }\n }\n\n setValues()\n\n watch(\n () => initData.dragging,\n (val) => {\n if (!val) {\n setValues()\n }\n }\n )\n\n watch(\n () => props.modelValue,\n (val, oldVal) => {\n if (\n initData.dragging ||\n (Array.isArray(val) &&\n Array.isArray(oldVal) &&\n val.every((item, index) => item === oldVal[index]))\n ) {\n return\n }\n setValues()\n }\n )\n\n watch(\n () => [props.min, props.max],\n () => {\n setValues()\n }\n )\n}\n\nconst useLifecycle = (props, initData, resetSize) => {\n const sliderWrapper: Ref<Nullable<HTMLElement>> = ref(null)\n\n onMounted(async () => {\n let valuetext\n if (props.range) {\n if (Array.isArray(props.modelValue)) {\n initData.firstValue = Math.max(props.min, props.modelValue[0])\n initData.secondValue = Math.min(props.max, props.modelValue[1])\n } else {\n initData.firstValue = props.min\n initData.secondValue = props.max\n }\n initData.oldValue = [initData.firstValue, initData.secondValue]\n valuetext = `${initData.firstValue}-${initData.secondValue}`\n } else {\n if (typeof props.modelValue !== 'number' || isNaN(props.modelValue)) {\n initData.firstValue = props.min\n } else {\n initData.firstValue = Math.min(\n props.max,\n Math.max(props.min, props.modelValue)\n )\n }\n initData.oldValue = initData.firstValue\n valuetext = initData.firstValue\n }\n\n sliderWrapper.value.setAttribute('aria-valuetext', valuetext)\n\n // label screen reader\n sliderWrapper.value.setAttribute(\n 'aria-label',\n props.label ? props.label : `slider between ${props.min} and ${props.max}`\n )\n\n on(window, 'resize', resetSize)\n\n await nextTick()\n resetSize()\n })\n\n onBeforeUnmount(() => {\n off(window, 'resize', resetSize)\n })\n\n return {\n sliderWrapper,\n }\n}\n</script>\n"],"names":["_createElementVNode","_createElementBlock","_createBlock"],"mappings":";;;;;;;;;;;;;IAEI;IACA;IAEA;IACC,eAAa,EAAE;;IAEf,kBAAgB;;;;;;;;eAOV;gBACE;oBACI;UACV;;;;;;;;;;MASDA;;4CAGmB;aACb;;;QAED;QAAwB,uBAAO;;;aAE9B;;QAEH;QACA;QACA;;;;;;wBAKW,EAAEC;;YAEb;YACA;;;;;;;oBAKO;;;;;;;;;;gCAONC;;kBAEG;wCACO,kBAAa;yBACf;;;;;;;;;;"}
1
+ {"version":3,"file":"index.vue_vue_type_template_id_24c42d04_lang.mjs","sources":["../../../../../../packages/components/slider/src/index.vue?vue&type=template&id=24c42d04&lang.js"],"sourcesContent":["<template>\n <div\n ref=\"sliderWrapper\"\n :class=\"sliderKls\"\n role=\"slider\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"max\"\n :aria-orientation=\"vertical ? 'vertical' : 'horizontal'\"\n :aria-disabled=\"sliderDisabled\"\n >\n <div\n ref=\"slider\"\n class=\"el-slider__runway\"\n :class=\"{ 'show-input': showInput && !range, disabled: sliderDisabled }\"\n :style=\"runwayStyle\"\n @click=\"onSliderClick\"\n >\n <div class=\"el-slider__bar\" :style=\"barStyle\"></div>\n <slider-button\n ref=\"firstButton\"\n :model-value=\"firstValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setFirstValue\"\n />\n <slider-button\n v-if=\"range\"\n ref=\"secondButton\"\n :model-value=\"secondValue\"\n :vertical=\"vertical\"\n :tooltip-class=\"tooltipClass\"\n @update:model-value=\"setSecondValue\"\n />\n <div v-if=\"showStops\">\n <div\n v-for=\"(item, key) in stops\"\n :key=\"key\"\n class=\"el-slider__stop\"\n :style=\"getStopStyle(item)\"\n ></div>\n </div>\n <template v-if=\"markList.length > 0\">\n <div>\n <div\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :style=\"getStopStyle(item.position)\"\n class=\"el-slider__stop el-slider__marks-stop\"\n ></div>\n </div>\n <div class=\"el-slider__marks\">\n <slider-marker\n v-for=\"(item, key) in markList\"\n :key=\"key\"\n :mark=\"item.mark\"\n :style=\"getStopStyle(item.position)\"\n />\n </div>\n </template>\n </div>\n <el-input-number\n v-if=\"showInput && !range\"\n ref=\"input\"\n :model-value=\"firstValue\"\n class=\"el-slider__input\"\n :step=\"step\"\n :disabled=\"sliderDisabled\"\n :controls=\"showInputControls\"\n :min=\"min\"\n :max=\"max\"\n :debounce=\"debounce\"\n :size=\"sliderInputSize\"\n @update:model-value=\"setFirstValue\"\n @change=\"emitChange\"\n />\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n nextTick,\n onBeforeUnmount,\n onMounted,\n provide,\n reactive,\n ref,\n toRefs,\n watch,\n} from 'vue'\nimport ElInputNumber from '@element-plus/components/input-number'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { off, on } from '@element-plus/utils/dom'\nimport { throwError } from '@element-plus/utils/error'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport { useSize } from '@element-plus/hooks'\nimport SliderButton from './button.vue'\nimport SliderMarker from './marker.vue'\nimport { useMarks } from './useMarks'\nimport { useSlide } from './useSlide'\nimport { useStops } from './useStops'\n\nimport type { PropType, Ref } from 'vue'\nimport type { ComponentSize, Nullable } from '@element-plus/utils/types'\n\nexport default defineComponent({\n name: 'ElSlider',\n\n components: {\n ElInputNumber,\n SliderButton,\n SliderMarker,\n },\n\n props: {\n modelValue: {\n type: [Number, Array] as PropType<number | number[]>,\n default: 0,\n },\n min: {\n type: Number,\n default: 0,\n },\n max: {\n type: Number,\n default: 100,\n },\n step: {\n type: Number,\n default: 1,\n },\n showInput: {\n type: Boolean,\n default: false,\n },\n showInputControls: {\n type: Boolean,\n default: true,\n },\n size: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n inputSize: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n showStops: {\n type: Boolean,\n default: false,\n },\n showTooltip: {\n type: Boolean,\n default: true,\n },\n formatTooltip: {\n type: Function as PropType<(val: number) => number | string>,\n default: undefined,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n range: {\n type: Boolean,\n default: false,\n },\n vertical: {\n type: Boolean,\n default: false,\n },\n height: {\n type: String,\n default: '',\n },\n debounce: {\n type: Number,\n default: 300,\n },\n label: {\n type: String,\n default: undefined,\n },\n tooltipClass: {\n type: String,\n default: undefined,\n },\n marks: Object,\n },\n\n emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT],\n\n setup(props, { emit }) {\n const initData = reactive({\n firstValue: 0,\n secondValue: 0,\n oldValue: 0,\n dragging: false,\n sliderSize: 1,\n })\n\n const {\n elFormItem,\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n minValue,\n maxValue,\n runwayStyle,\n barStyle,\n resetSize,\n emitChange,\n onSliderClick,\n setFirstValue,\n setSecondValue,\n } = useSlide(props, initData, emit)\n\n const { stops, getStopStyle } = useStops(\n props,\n initData,\n minValue,\n maxValue\n )\n\n const sliderWrapperSize = useSize()\n const sliderInputSize = computed(\n () => props.inputSize || sliderWrapperSize.value\n )\n\n const prefix = 'el-slider'\n const sliderKls = computed(() => [\n prefix,\n `${prefix}--${sliderWrapperSize.value}`,\n props.vertical ? 'is-vertical' : '',\n props.showInput ? 'el-slider--with-input' : '',\n ])\n\n const markList = useMarks(props)\n\n useWatch(props, initData, minValue, maxValue, emit, elFormItem)\n\n const precision = computed(() => {\n const precisions = [props.min, props.max, props.step].map((item) => {\n const decimal = `${item}`.split('.')[1]\n return decimal ? decimal.length : 0\n })\n return Math.max.apply(null, precisions)\n })\n\n const { sliderWrapper } = useLifecycle(props, initData, resetSize)\n\n const { firstValue, secondValue, oldValue, dragging, sliderSize } =\n toRefs(initData)\n\n const updateDragging = (val: boolean) => {\n initData.dragging = val\n }\n\n provide('SliderProvider', {\n ...toRefs(props),\n sliderSize,\n disabled: sliderDisabled,\n precision,\n emitChange,\n resetSize,\n updateDragging,\n })\n\n return {\n firstValue,\n secondValue,\n oldValue,\n dragging,\n sliderSize,\n\n slider,\n firstButton,\n secondButton,\n sliderDisabled,\n runwayStyle,\n barStyle,\n emitChange,\n onSliderClick,\n getStopStyle,\n setFirstValue,\n setSecondValue,\n\n stops,\n markList,\n\n sliderWrapper,\n sliderWrapperSize,\n sliderInputSize,\n sliderKls,\n }\n },\n})\n\nconst useWatch = (props, initData, minValue, maxValue, emit, elFormItem) => {\n const _emit = (val: number | number[]) => {\n emit(UPDATE_MODEL_EVENT, val)\n emit(INPUT_EVENT, val)\n }\n\n const valueChanged = () => {\n if (props.range) {\n return ![minValue.value, maxValue.value].every(\n (item, index) => item === initData.oldValue[index]\n )\n } else {\n return props.modelValue !== initData.oldValue\n }\n }\n\n const setValues = () => {\n if (props.min > props.max) {\n throwError('Slider', 'min should not be greater than max.')\n return\n }\n const val = props.modelValue\n if (props.range && Array.isArray(val)) {\n if (val[1] < props.min) {\n _emit([props.min, props.min])\n } else if (val[0] > props.max) {\n _emit([props.max, props.max])\n } else if (val[0] < props.min) {\n _emit([props.min, val[1]])\n } else if (val[1] > props.max) {\n _emit([val[0], props.max])\n } else {\n initData.firstValue = val[0]\n initData.secondValue = val[1]\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val.slice()\n }\n }\n } else if (!props.range && typeof val === 'number' && !isNaN(val)) {\n if (val < props.min) {\n _emit(props.min)\n } else if (val > props.max) {\n _emit(props.max)\n } else {\n initData.firstValue = val\n if (valueChanged()) {\n elFormItem.validate?.('change')\n initData.oldValue = val\n }\n }\n }\n }\n\n setValues()\n\n watch(\n () => initData.dragging,\n (val) => {\n if (!val) {\n setValues()\n }\n }\n )\n\n watch(\n () => props.modelValue,\n (val, oldVal) => {\n if (\n initData.dragging ||\n (Array.isArray(val) &&\n Array.isArray(oldVal) &&\n val.every((item, index) => item === oldVal[index]))\n ) {\n return\n }\n setValues()\n }\n )\n\n watch(\n () => [props.min, props.max],\n () => {\n setValues()\n }\n )\n}\n\nconst useLifecycle = (props, initData, resetSize) => {\n const sliderWrapper: Ref<Nullable<HTMLElement>> = ref(null)\n\n onMounted(async () => {\n let valuetext\n if (props.range) {\n if (Array.isArray(props.modelValue)) {\n initData.firstValue = Math.max(props.min, props.modelValue[0])\n initData.secondValue = Math.min(props.max, props.modelValue[1])\n } else {\n initData.firstValue = props.min\n initData.secondValue = props.max\n }\n initData.oldValue = [initData.firstValue, initData.secondValue]\n valuetext = `${initData.firstValue}-${initData.secondValue}`\n } else {\n if (typeof props.modelValue !== 'number' || isNaN(props.modelValue)) {\n initData.firstValue = props.min\n } else {\n initData.firstValue = Math.min(\n props.max,\n Math.max(props.min, props.modelValue)\n )\n }\n initData.oldValue = initData.firstValue\n valuetext = initData.firstValue\n }\n\n sliderWrapper.value.setAttribute('aria-valuetext', valuetext)\n\n // label screen reader\n sliderWrapper.value.setAttribute(\n 'aria-label',\n props.label ? props.label : `slider between ${props.min} and ${props.max}`\n )\n\n on(window, 'resize', resetSize)\n\n await nextTick()\n resetSize()\n })\n\n onBeforeUnmount(() => {\n off(window, 'resize', resetSize)\n })\n\n return {\n sliderWrapper,\n }\n}\n</script>\n"],"names":["_createElementVNode","_createElementBlock"],"mappings":";;;;;;;;;;;;;IAEI;IACC;IACD;IACC,eAAa,EAAE;;IAEfA,mBAAkB;mBACL;;;MAGZ;;MAGCA;aACK;;;;QAEuB,KAAK;;;QAEhC;QACC;gBACQ,EAAE;;QAEV;;;;;;;oBAMQ;0BACKC,kBAAc;;;;;;;;mBAMtB;;oBAEE;;;;;qBAGe;;;gCAErB;;;;kBAIE,OAAM;;;;;;;kBAML,KAAK;;kBAEL;;;;;;;;;;;;iBASD;;;;;;"}
@@ -18,11 +18,13 @@ export declare const ElSwitch: import("../../utils/types").SFCWithInstall<import
18
18
  readonly id: StringConstructor;
19
19
  readonly loading: import("../../utils/props").BuildPropReturn<BooleanConstructor, false, unknown, unknown, unknown>;
20
20
  readonly beforeChange: import("../../utils/props").BuildPropReturn<import("../../utils/props").PropWrapper<() => boolean | Promise<boolean>>, unknown, unknown, unknown, unknown>;
21
+ readonly size: import("../../utils/props").BuildPropReturn<(new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize))[], unknown, unknown, unknown, unknown>;
21
22
  }, {
22
23
  input: import("vue").Ref<HTMLInputElement | undefined>;
23
24
  core: import("vue").Ref<HTMLSpanElement | undefined>;
24
25
  switchDisabled: import("vue").ComputedRef<boolean>;
25
26
  checked: import("vue").ComputedRef<boolean>;
27
+ switchKls: import("vue").ComputedRef<string[]>;
26
28
  handleChange: () => void;
27
29
  switchValue: () => void;
28
30
  focus: () => void;
@@ -50,11 +52,12 @@ export declare const ElSwitch: import("../../utils/types").SFCWithInstall<import
50
52
  readonly id?: unknown;
51
53
  readonly loading?: unknown;
52
54
  readonly beforeChange?: unknown;
55
+ readonly size?: unknown;
53
56
  } & {
54
57
  disabled: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
55
58
  loading: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
56
- name: string;
57
59
  modelValue: import("../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
60
+ name: string;
58
61
  width: number;
59
62
  borderColor: string;
60
63
  validateEvent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
@@ -69,6 +72,7 @@ export declare const ElSwitch: import("../../utils/types").SFCWithInstall<import
69
72
  activeValue: import("../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
70
73
  inactiveValue: import("../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
71
74
  } & {
75
+ size?: import("../../utils/props").BuildPropType<(new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize))[], unknown, unknown> | undefined;
72
76
  id?: string | undefined;
73
77
  beforeChange?: (() => boolean | Promise<boolean>) | undefined;
74
78
  }> & {
@@ -76,10 +80,11 @@ export declare const ElSwitch: import("../../utils/types").SFCWithInstall<import
76
80
  onInput?: ((val: string | number | boolean) => any) | undefined;
77
81
  "onUpdate:modelValue"?: ((val: string | number | boolean) => any) | undefined;
78
82
  }, {
83
+ size: import("../../utils/props").BuildPropType<(new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../utils/types").ComponentSize & {}) | (() => import("../../utils/types").ComponentSize))[], unknown, unknown>;
79
84
  disabled: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
80
85
  loading: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
81
- name: string;
82
86
  modelValue: import("../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
87
+ name: string;
83
88
  width: number;
84
89
  borderColor: string;
85
90
  validateEvent: import("../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
@@ -1,3 +1,4 @@
1
+ import type { ComponentSize } from 'element-plus/es/utils/types';
1
2
  import type Switch from './switch.vue';
2
3
  import type { Component, ExtractPropTypes } from 'vue';
3
4
  export declare const switchProps: {
@@ -20,6 +21,7 @@ export declare const switchProps: {
20
21
  readonly id: StringConstructor;
21
22
  readonly loading: import("element-plus/es/utils/props").BuildPropReturn<BooleanConstructor, false, unknown, unknown, unknown>;
22
23
  readonly beforeChange: import("element-plus/es/utils/props").BuildPropReturn<import("element-plus/es/utils/props").PropWrapper<() => Promise<boolean> | boolean>, unknown, unknown, unknown, unknown>;
24
+ readonly size: import("element-plus/es/utils/props").BuildPropReturn<(new (...args: any[]) => ComponentSize & {}) | (() => ComponentSize) | ((new (...args: any[]) => ComponentSize & {}) | (() => ComponentSize))[], unknown, unknown, unknown, unknown>;
23
25
  };
24
26
  export declare type SwitchProps = ExtractPropTypes<typeof switchProps>;
25
27
  export declare const switchEmits: {
@@ -1,6 +1,7 @@
1
1
  import { buildProps, definePropType } from '../../../utils/props.mjs';
2
2
  import { UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT } from '../../../utils/constants.mjs';
3
3
  import { isBool, isNumber } from '../../../utils/util.mjs';
4
+ import { isValidComponentSize } from '../../../utils/validators.mjs';
4
5
  import { isString } from '@vue/shared';
5
6
 
6
7
  const switchProps = buildProps({
@@ -75,6 +76,10 @@ const switchProps = buildProps({
75
76
  },
76
77
  beforeChange: {
77
78
  type: definePropType(Function)
79
+ },
80
+ size: {
81
+ type: String,
82
+ validator: isValidComponentSize
78
83
  }
79
84
  });
80
85
  const switchEmits = {
@@ -1 +1 @@
1
- {"version":3,"file":"switch.mjs","sources":["../../../../../../packages/components/switch/src/switch.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils/props'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { isBool, isNumber, isString } from '@element-plus/utils/util'\nimport type Switch from './switch.vue'\nimport type { Component, ExtractPropTypes } from 'vue'\n\nexport const switchProps = buildProps({\n modelValue: {\n type: [Boolean, String, Number],\n default: false,\n },\n value: {\n type: [Boolean, String, Number],\n default: false,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n width: {\n type: Number,\n default: 40,\n },\n inlinePrompt: {\n type: Boolean,\n default: false,\n },\n activeIcon: {\n type: definePropType<string | Component>([String, Object, Function]),\n default: '',\n },\n inactiveIcon: {\n type: definePropType<string | Component>([String, Object, Function]),\n default: '',\n },\n activeText: {\n type: String,\n default: '',\n },\n inactiveText: {\n type: String,\n default: '',\n },\n activeColor: {\n type: String,\n default: '',\n },\n inactiveColor: {\n type: String,\n default: '',\n },\n borderColor: {\n type: String,\n default: '',\n },\n activeValue: {\n type: [Boolean, String, Number],\n default: true,\n },\n inactiveValue: {\n type: [Boolean, String, Number],\n default: false,\n },\n name: {\n type: String,\n default: '',\n },\n validateEvent: {\n type: Boolean,\n default: true,\n },\n id: String,\n loading: {\n type: Boolean,\n default: false,\n },\n beforeChange: {\n type: definePropType<() => Promise<boolean> | boolean>(Function),\n },\n} as const)\n\nexport type SwitchProps = ExtractPropTypes<typeof switchProps>\n\nexport const switchEmits = {\n [UPDATE_MODEL_EVENT]: (val: boolean | string | number) =>\n isBool(val) || isString(val) || isNumber(val),\n [CHANGE_EVENT]: (val: boolean | string | number) =>\n isBool(val) || isString(val) || isNumber(val),\n [INPUT_EVENT]: (val: boolean | string | number) =>\n isBool(val) || isString(val) || isNumber(val),\n}\nexport type SwitchEmits = typeof switchEmits\n\nexport type SwitchInstance = InstanceType<typeof Switch>\n"],"names":[],"mappings":";;;;;AAOY,MAAC,WAAW,GAAG,UAAU,CAAC;AACtC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpD,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpD,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,YAAY,EAAE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AK,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC;AACxE,EAAE,CAAC,WAAW,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC;AACvE;;;;"}
1
+ {"version":3,"file":"switch.mjs","sources":["../../../../../../packages/components/switch/src/switch.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils/props'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { isBool, isNumber, isString } from '@element-plus/utils/util'\nimport { isValidComponentSize } from '@element-plus/utils/validators'\nimport type { ComponentSize } from '@element-plus/utils/types'\nimport type Switch from './switch.vue'\nimport type { Component, ExtractPropTypes, PropType } from 'vue'\n\nexport const switchProps = buildProps({\n modelValue: {\n type: [Boolean, String, Number],\n default: false,\n },\n value: {\n type: [Boolean, String, Number],\n default: false,\n },\n disabled: {\n type: Boolean,\n default: false,\n },\n width: {\n type: Number,\n default: 40,\n },\n inlinePrompt: {\n type: Boolean,\n default: false,\n },\n activeIcon: {\n type: definePropType<string | Component>([String, Object, Function]),\n default: '',\n },\n inactiveIcon: {\n type: definePropType<string | Component>([String, Object, Function]),\n default: '',\n },\n activeText: {\n type: String,\n default: '',\n },\n inactiveText: {\n type: String,\n default: '',\n },\n activeColor: {\n type: String,\n default: '',\n },\n inactiveColor: {\n type: String,\n default: '',\n },\n borderColor: {\n type: String,\n default: '',\n },\n activeValue: {\n type: [Boolean, String, Number],\n default: true,\n },\n inactiveValue: {\n type: [Boolean, String, Number],\n default: false,\n },\n name: {\n type: String,\n default: '',\n },\n validateEvent: {\n type: Boolean,\n default: true,\n },\n id: String,\n loading: {\n type: Boolean,\n default: false,\n },\n beforeChange: {\n type: definePropType<() => Promise<boolean> | boolean>(Function),\n },\n size: {\n type: String as PropType<ComponentSize>,\n validator: isValidComponentSize,\n },\n} as const)\n\nexport type SwitchProps = ExtractPropTypes<typeof switchProps>\n\nexport const switchEmits = {\n [UPDATE_MODEL_EVENT]: (val: boolean | string | number) =>\n isBool(val) || isString(val) || isNumber(val),\n [CHANGE_EVENT]: (val: boolean | string | number) =>\n isBool(val) || isString(val) || isNumber(val),\n [INPUT_EVENT]: (val: boolean | string | number) =>\n isBool(val) || isString(val) || isNumber(val),\n}\nexport type SwitchEmits = typeof switchEmits\n\nexport type SwitchInstance = InstanceType<typeof Switch>\n"],"names":[],"mappings":";;;;;;AAQY,MAAC,WAAW,GAAG,UAAU,CAAC;AACtC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;AACnC,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpD,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpD,IAAI,OAAO,EAAE,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AG;AACH,CAAC,EAAE;AACS,MAAC,WAAW,GAAG;AAC3B,EAAE,CAAC,kBAAkB,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC;AAC9E,EAAE,CAAC,YAAY,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC;AACxE,EAAE,CAAC,WAAW,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC;AACvE;;;;"}
@@ -18,11 +18,13 @@ declare const _default: import("vue").DefineComponent<{
18
18
  readonly id: StringConstructor;
19
19
  readonly loading: import("../../../utils/props").BuildPropReturn<BooleanConstructor, false, unknown, unknown, unknown>;
20
20
  readonly beforeChange: import("../../../utils/props").BuildPropReturn<import("../../../utils/props").PropWrapper<() => boolean | Promise<boolean>>, unknown, unknown, unknown, unknown>;
21
+ readonly size: import("../../../utils/props").BuildPropReturn<(new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize))[], unknown, unknown, unknown, unknown>;
21
22
  }, {
22
23
  input: import("vue").Ref<HTMLInputElement | undefined>;
23
24
  core: import("vue").Ref<HTMLSpanElement | undefined>;
24
25
  switchDisabled: import("vue").ComputedRef<boolean>;
25
26
  checked: import("vue").ComputedRef<boolean>;
27
+ switchKls: import("vue").ComputedRef<string[]>;
26
28
  handleChange: () => void;
27
29
  switchValue: () => void;
28
30
  focus: () => void;
@@ -50,11 +52,12 @@ declare const _default: import("vue").DefineComponent<{
50
52
  readonly id?: unknown;
51
53
  readonly loading?: unknown;
52
54
  readonly beforeChange?: unknown;
55
+ readonly size?: unknown;
53
56
  } & {
54
57
  disabled: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
55
58
  loading: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
56
- name: string;
57
59
  modelValue: import("../../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
60
+ name: string;
58
61
  width: number;
59
62
  borderColor: string;
60
63
  validateEvent: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
@@ -69,6 +72,7 @@ declare const _default: import("vue").DefineComponent<{
69
72
  activeValue: import("../../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
70
73
  inactiveValue: import("../../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
71
74
  } & {
75
+ size?: import("../../../utils/props").BuildPropType<(new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize))[], unknown, unknown> | undefined;
72
76
  id?: string | undefined;
73
77
  beforeChange?: (() => boolean | Promise<boolean>) | undefined;
74
78
  }> & {
@@ -76,10 +80,11 @@ declare const _default: import("vue").DefineComponent<{
76
80
  onInput?: ((val: string | number | boolean) => any) | undefined;
77
81
  "onUpdate:modelValue"?: ((val: string | number | boolean) => any) | undefined;
78
82
  }, {
83
+ size: import("../../../utils/props").BuildPropType<(new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize) | ((new (...args: any[]) => import("../../../utils/types").ComponentSize & {}) | (() => import("../../../utils/types").ComponentSize))[], unknown, unknown>;
79
84
  disabled: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
80
85
  loading: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
81
- name: string;
82
86
  modelValue: import("../../../utils/props").BuildPropType<readonly [BooleanConstructor, StringConstructor, NumberConstructor], unknown, unknown>;
87
+ name: string;
83
88
  width: number;
84
89
  borderColor: string;
85
90
  validateEvent: import("../../../utils/props").BuildPropType<BooleanConstructor, unknown, unknown>;
@@ -8,7 +8,7 @@ import { UPDATE_MODEL_EVENT, CHANGE_EVENT, INPUT_EVENT } from '../../../utils/co
8
8
  import '../../../hooks/index.mjs';
9
9
  import { switchProps, switchEmits } from './switch.mjs';
10
10
  import { useFormItem } from '../../../hooks/use-form-item/index.mjs';
11
- import { useDisabled } from '../../../hooks/use-common-props/index.mjs';
11
+ import { useDisabled, useSize } from '../../../hooks/use-common-props/index.mjs';
12
12
 
13
13
  const COMPONENT_NAME = "ElSwitch";
14
14
  var script = defineComponent({
@@ -19,9 +19,17 @@ var script = defineComponent({
19
19
  setup(props, { emit }) {
20
20
  const { formItem } = useFormItem();
21
21
  const switchDisabled = useDisabled(computed(() => props.loading));
22
+ const switchSize = useSize();
22
23
  const isModelValue = ref(props.modelValue !== false);
23
24
  const input = ref();
24
25
  const core = ref();
26
+ const prefix = "el-switch";
27
+ const switchKls = computed(() => [
28
+ prefix,
29
+ `${prefix}--${switchSize.value}`,
30
+ switchDisabled.value ? "is-disabled" : "",
31
+ checked.value ? "is-checked" : ""
32
+ ]);
25
33
  watch(() => props.modelValue, () => {
26
34
  isModelValue.value = true;
27
35
  });
@@ -106,6 +114,7 @@ var script = defineComponent({
106
114
  core,
107
115
  switchDisabled,
108
116
  checked,
117
+ switchKls,
109
118
  handleChange,
110
119
  switchValue,
111
120
  focus
@@ -1 +1 @@
1
- {"version":3,"file":"switch.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/switch/src/switch.vue"],"sourcesContent":["<template>\n <div\n class=\"el-switch\"\n :class=\"{ 'is-disabled': switchDisabled, 'is-checked': checked }\"\n role=\"switch\"\n :aria-checked=\"checked\"\n :aria-disabled=\"switchDisabled\"\n @click.prevent=\"switchValue\"\n >\n <input\n :id=\"id\"\n ref=\"input\"\n class=\"el-switch__input\"\n type=\"checkbox\"\n :name=\"name\"\n :true-value=\"activeValue\"\n :false-value=\"inactiveValue\"\n :disabled=\"switchDisabled\"\n @change=\"handleChange\"\n @keydown.enter=\"switchValue\"\n />\n <span\n v-if=\"!inlinePrompt && (inactiveIcon || inactiveText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--left',\n !checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"inactiveIcon\"><component :is=\"inactiveIcon\" /></el-icon>\n <span v-if=\"!inactiveIcon && inactiveText\" :aria-hidden=\"checked\">{{\n inactiveText\n }}</span>\n </span>\n <span\n ref=\"core\"\n class=\"el-switch__core\"\n :style=\"{ width: (width || 40) + 'px' }\"\n >\n <div v-if=\"inlinePrompt\" class=\"el-switch__inner\">\n <template v-if=\"activeIcon || inactiveIcon\">\n <el-icon\n v-if=\"activeIcon\"\n class=\"is-icon\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"activeIcon\" />\n </el-icon>\n <el-icon\n v-if=\"inactiveIcon\"\n class=\"is-icon\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"inactiveIcon\" />\n </el-icon>\n </template>\n <template v-else-if=\"activeText || inactiveIcon\">\n <span\n v-if=\"activeText\"\n class=\"is-text\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"!checked\"\n >\n {{ activeText.substr(0, 1) }}\n </span>\n <span\n v-if=\"inactiveText\"\n class=\"is-text\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"checked\"\n >\n {{ inactiveText.substr(0, 1) }}\n </span>\n </template>\n </div>\n <div class=\"el-switch__action\">\n <el-icon v-if=\"loading\" class=\"is-loading\"><loading /></el-icon>\n </div>\n </span>\n <span\n v-if=\"!inlinePrompt && (activeIcon || activeText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--right',\n checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"activeIcon\"><component :is=\"activeIcon\" /></el-icon>\n <span v-if=\"!activeIcon && activeText\" :aria-hidden=\"!checked\">{{\n activeText\n }}</span>\n </span>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, computed, onMounted, ref, nextTick, watch } from 'vue'\nimport { isPromise } from '@vue/shared'\nimport { isBool } from '@element-plus/utils/util'\nimport { throwError, debugWarn } from '@element-plus/utils/error'\nimport ElIcon from '@element-plus/components/icon'\nimport { Loading } from '@element-plus/icons-vue'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { useDisabled, useFormItem } from '@element-plus/hooks'\nimport { switchProps, switchEmits } from './switch'\n\nconst COMPONENT_NAME = 'ElSwitch'\n\nexport default defineComponent({\n name: COMPONENT_NAME,\n components: { ElIcon, Loading },\n\n props: switchProps,\n emits: switchEmits,\n\n setup(props, { emit }) {\n const { formItem } = useFormItem()\n const switchDisabled = useDisabled(computed(() => props.loading))\n\n const isModelValue = ref(props.modelValue !== false)\n const input = ref<HTMLInputElement>()\n const core = ref<HTMLSpanElement>()\n\n watch(\n () => props.modelValue,\n () => {\n isModelValue.value = true\n }\n )\n\n watch(\n () => props.value,\n () => {\n isModelValue.value = false\n }\n )\n\n const actualValue = computed(() => {\n return isModelValue.value ? props.modelValue : props.value\n })\n\n const checked = computed(() => actualValue.value === props.activeValue)\n\n if (![props.activeValue, props.inactiveValue].includes(actualValue.value)) {\n emit(UPDATE_MODEL_EVENT, props.inactiveValue)\n emit(CHANGE_EVENT, props.inactiveValue)\n emit(INPUT_EVENT, props.inactiveValue)\n }\n\n watch(checked, () => {\n input.value!.checked = checked.value\n\n if (props.activeColor || props.inactiveColor) {\n setBackgroundColor()\n }\n\n if (props.validateEvent) {\n formItem?.validate?.('change')\n }\n })\n\n const handleChange = (): void => {\n const val = checked.value ? props.inactiveValue : props.activeValue\n emit(UPDATE_MODEL_EVENT, val)\n emit(CHANGE_EVENT, val)\n emit(INPUT_EVENT, val)\n nextTick(() => {\n input.value!.checked = checked.value\n })\n }\n\n const switchValue = (): void => {\n if (switchDisabled.value) return\n\n const { beforeChange } = props\n if (!beforeChange) {\n handleChange()\n return\n }\n\n const shouldChange = beforeChange()\n\n const isExpectType = [isPromise(shouldChange), isBool(shouldChange)].some(\n (i) => i\n )\n if (!isExpectType) {\n throwError(\n COMPONENT_NAME,\n 'beforeChange must return type `Promise<boolean>` or `boolean`'\n )\n }\n\n if (isPromise(shouldChange)) {\n shouldChange\n .then((result) => {\n if (result) {\n handleChange()\n }\n })\n .catch((e) => {\n debugWarn(COMPONENT_NAME, `some error occurred: ${e}`)\n })\n } else if (shouldChange) {\n handleChange()\n }\n }\n\n const setBackgroundColor = (): void => {\n const newColor = checked.value ? props.activeColor : props.inactiveColor\n const coreEl = core.value\n if (props.borderColor) coreEl!.style.borderColor = props.borderColor\n else if (!props.borderColor) coreEl!.style.borderColor = newColor\n coreEl!.style.backgroundColor = newColor\n ;(coreEl!.children[0] as HTMLDivElement).style.color = newColor\n }\n\n const focus = (): void => {\n input.value?.focus?.()\n }\n\n onMounted(() => {\n if (props.activeColor || props.inactiveColor || props.borderColor) {\n setBackgroundColor()\n }\n\n input.value!.checked = checked.value\n })\n\n return {\n input,\n core,\n switchDisabled,\n checked,\n handleChange,\n switchValue,\n focus,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;AA4GA,oBAAoB,GAAG,WAAW;;AAElC,EAAE,IAAI,EAAE;;AAER,EAAE,KAAK,EAAE,WAAW;EAClB,OAAO,WAAW;EAClB,KAAK,CAAC,SAAS,IAAI,IAAI;;IAErB,MAAM;IACN,MAAM;;IAEN,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,MAAM,MAAM,KAAK,WAAW,EAAE;MAC5B,YAAY,CAAC,QAAQ,IAAI,CAAC;;IAE5B,MAAM,MAAM,KAAK,MAAM,EAAE,MAAM;MAC7B,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC;KAC5B,CAAC,CAAC;;MAED;MACA,CAAC;UACG;QACF,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE;MACvB;;;KAGD;SACI,CAAC,OAAO,EAAE;MACb,IAAI,EAAE;WACD,CAAC,KAAK,CAAC,OAAO;MACnB;;;MAGA,IAAI,KAAK,CAAC,aAAa,EAAE;QACvB,CAAC,EAAE,GAAG,QAAQ,IAAI,IAAI,QAAQ,CAAC,GAAG,SAAS,QAAQ;;;IAGvD,MAAM,YAAY,GAAG;;UAEf,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;MAC9B,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC;MACvB,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC;MACvB,QAAQ,CAAC,MAAM;;;KAGhB,CAAC;UACI,WAAW,GAAG,MAAM;;eAEf;YACH,EAAE,YAAY;MACpB;;eAES;;MAET;;;QAGE,UAAU,CAAC,gBAAgB;OAC5B;MACD,IAAI,SAAS,CAAC,YAAY,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,CAAC;UACjB,IAAI,MAAM,EAAE;YACV;WACD;;;;OAIJ,MAAM,IAAI,YAAY,EAAE;oBACX,EAAE,CAAC;;MAEjB;UACI;YACE,QAAQ;YACR;MACN;;eAES,CAAC,KAAK,CAAC,WAAW;;MAE3B,MAAM,CAAC,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;YAClC,CAAC;MACP;UACI,KAAK,GAAG;UACR,EAAE,EAAE,EAAE,CAAC;YACL,CAAC,EAAE,GAAG,KAAK,CAAC;;;MAGlB;;OAEC;WACI,CAAC,KAAK,CAAC;;;;;;aAML;kBACK;;MAEZ,KAAK;;;;;;;"}
1
+ {"version":3,"file":"switch.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/switch/src/switch.vue"],"sourcesContent":["<template>\n <div\n :class=\"switchKls\"\n role=\"switch\"\n :aria-checked=\"checked\"\n :aria-disabled=\"switchDisabled\"\n @click.prevent=\"switchValue\"\n >\n <input\n :id=\"id\"\n ref=\"input\"\n class=\"el-switch__input\"\n type=\"checkbox\"\n :name=\"name\"\n :true-value=\"activeValue\"\n :false-value=\"inactiveValue\"\n :disabled=\"switchDisabled\"\n @change=\"handleChange\"\n @keydown.enter=\"switchValue\"\n />\n <span\n v-if=\"!inlinePrompt && (inactiveIcon || inactiveText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--left',\n !checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"inactiveIcon\"><component :is=\"inactiveIcon\" /></el-icon>\n <span v-if=\"!inactiveIcon && inactiveText\" :aria-hidden=\"checked\">{{\n inactiveText\n }}</span>\n </span>\n <span\n ref=\"core\"\n class=\"el-switch__core\"\n :style=\"{ width: (width || 40) + 'px' }\"\n >\n <div v-if=\"inlinePrompt\" class=\"el-switch__inner\">\n <template v-if=\"activeIcon || inactiveIcon\">\n <el-icon\n v-if=\"activeIcon\"\n class=\"is-icon\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"activeIcon\" />\n </el-icon>\n <el-icon\n v-if=\"inactiveIcon\"\n class=\"is-icon\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"inactiveIcon\" />\n </el-icon>\n </template>\n <template v-else-if=\"activeText || inactiveIcon\">\n <span\n v-if=\"activeText\"\n class=\"is-text\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"!checked\"\n >\n {{ activeText.substr(0, 1) }}\n </span>\n <span\n v-if=\"inactiveText\"\n class=\"is-text\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"checked\"\n >\n {{ inactiveText.substr(0, 1) }}\n </span>\n </template>\n </div>\n <div class=\"el-switch__action\">\n <el-icon v-if=\"loading\" class=\"is-loading\"><loading /></el-icon>\n </div>\n </span>\n <span\n v-if=\"!inlinePrompt && (activeIcon || activeText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--right',\n checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"activeIcon\"><component :is=\"activeIcon\" /></el-icon>\n <span v-if=\"!activeIcon && activeText\" :aria-hidden=\"!checked\">{{\n activeText\n }}</span>\n </span>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, computed, onMounted, ref, nextTick, watch } from 'vue'\nimport { isPromise } from '@vue/shared'\nimport { isBool } from '@element-plus/utils/util'\nimport { throwError, debugWarn } from '@element-plus/utils/error'\nimport ElIcon from '@element-plus/components/icon'\nimport { Loading } from '@element-plus/icons-vue'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { useDisabled, useFormItem, useSize } from '@element-plus/hooks'\nimport { switchProps, switchEmits } from './switch'\n\nconst COMPONENT_NAME = 'ElSwitch'\n\nexport default defineComponent({\n name: COMPONENT_NAME,\n components: { ElIcon, Loading },\n\n props: switchProps,\n emits: switchEmits,\n\n setup(props, { emit }) {\n const { formItem } = useFormItem()\n const switchDisabled = useDisabled(computed(() => props.loading))\n\n const switchSize = useSize()\n const isModelValue = ref(props.modelValue !== false)\n const input = ref<HTMLInputElement>()\n const core = ref<HTMLSpanElement>()\n\n const prefix = 'el-switch'\n const switchKls = computed(() => [\n prefix,\n `${prefix}--${switchSize.value}`,\n switchDisabled.value ? 'is-disabled' : '',\n checked.value ? 'is-checked' : '',\n ])\n\n watch(\n () => props.modelValue,\n () => {\n isModelValue.value = true\n }\n )\n\n watch(\n () => props.value,\n () => {\n isModelValue.value = false\n }\n )\n\n const actualValue = computed(() => {\n return isModelValue.value ? props.modelValue : props.value\n })\n\n const checked = computed(() => actualValue.value === props.activeValue)\n\n if (![props.activeValue, props.inactiveValue].includes(actualValue.value)) {\n emit(UPDATE_MODEL_EVENT, props.inactiveValue)\n emit(CHANGE_EVENT, props.inactiveValue)\n emit(INPUT_EVENT, props.inactiveValue)\n }\n\n watch(checked, () => {\n input.value!.checked = checked.value\n\n if (props.activeColor || props.inactiveColor) {\n setBackgroundColor()\n }\n\n if (props.validateEvent) {\n formItem?.validate?.('change')\n }\n })\n\n const handleChange = (): void => {\n const val = checked.value ? props.inactiveValue : props.activeValue\n emit(UPDATE_MODEL_EVENT, val)\n emit(CHANGE_EVENT, val)\n emit(INPUT_EVENT, val)\n nextTick(() => {\n input.value!.checked = checked.value\n })\n }\n\n const switchValue = (): void => {\n if (switchDisabled.value) return\n\n const { beforeChange } = props\n if (!beforeChange) {\n handleChange()\n return\n }\n\n const shouldChange = beforeChange()\n\n const isExpectType = [isPromise(shouldChange), isBool(shouldChange)].some(\n (i) => i\n )\n if (!isExpectType) {\n throwError(\n COMPONENT_NAME,\n 'beforeChange must return type `Promise<boolean>` or `boolean`'\n )\n }\n\n if (isPromise(shouldChange)) {\n shouldChange\n .then((result) => {\n if (result) {\n handleChange()\n }\n })\n .catch((e) => {\n debugWarn(COMPONENT_NAME, `some error occurred: ${e}`)\n })\n } else if (shouldChange) {\n handleChange()\n }\n }\n\n const setBackgroundColor = (): void => {\n const newColor = checked.value ? props.activeColor : props.inactiveColor\n const coreEl = core.value\n if (props.borderColor) coreEl!.style.borderColor = props.borderColor\n else if (!props.borderColor) coreEl!.style.borderColor = newColor\n coreEl!.style.backgroundColor = newColor\n ;(coreEl!.children[0] as HTMLDivElement).style.color = newColor\n }\n\n const focus = (): void => {\n input.value?.focus?.()\n }\n\n onMounted(() => {\n if (props.activeColor || props.inactiveColor || props.borderColor) {\n setBackgroundColor()\n }\n\n input.value!.checked = checked.value\n })\n\n return {\n input,\n core,\n switchDisabled,\n checked,\n switchKls,\n handleChange,\n switchValue,\n focus,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;AA2GA,oBAAoB,GAAG,WAAW;;AAElC,EAAE,IAAI,EAAE;;AAER,EAAE,KAAK,EAAE,WAAW;EAClB,OAAO,WAAW;EAClB,KAAK,CAAC,SAAS,IAAI,IAAI;;IAErB,MAAM;IACN,MAAM,UAAU;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AAC,CAAC,KAAK;;;;QAIhB,YAAY,EAAE;OACf;;UAEG,qBAAqB;MACzB,MAAM,QAAQ,GAAG;YACX,MAAM,GAAG;UACX;;;QAGF,MAAM,CAAC,KAAK,CAAC,WAAW,GAAG;;MAE7B,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC;;;MAG1C,IAAI,EAAE,EAAE,EAAE,CAAC;SACR,GAAG,CAAC,EAAE,GAAG;;aAEL,CAAC,MAAM;;;;MAId,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO;;WAExB;;;;;eAKI;kBACG;;MAEZ,KAAK;;;;;;;"}
@@ -15,7 +15,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
15
15
  const _component_el_icon = resolveComponent("el-icon");
16
16
  const _component_loading = resolveComponent("loading");
17
17
  return openBlock(), createElementBlock("div", {
18
- class: normalizeClass(["el-switch", { "is-disabled": _ctx.switchDisabled, "is-checked": _ctx.checked }]),
18
+ class: normalizeClass(_ctx.switchKls),
19
19
  role: "switch",
20
20
  "aria-checked": _ctx.checked,
21
21
  "aria-disabled": _ctx.switchDisabled,
@@ -1 +1 @@
1
- {"version":3,"file":"switch.vue_vue_type_template_id_538fbc85_lang.mjs","sources":["../../../../../../packages/components/switch/src/switch.vue?vue&type=template&id=538fbc85&lang.js"],"sourcesContent":["<template>\n <div\n class=\"el-switch\"\n :class=\"{ 'is-disabled': switchDisabled, 'is-checked': checked }\"\n role=\"switch\"\n :aria-checked=\"checked\"\n :aria-disabled=\"switchDisabled\"\n @click.prevent=\"switchValue\"\n >\n <input\n :id=\"id\"\n ref=\"input\"\n class=\"el-switch__input\"\n type=\"checkbox\"\n :name=\"name\"\n :true-value=\"activeValue\"\n :false-value=\"inactiveValue\"\n :disabled=\"switchDisabled\"\n @change=\"handleChange\"\n @keydown.enter=\"switchValue\"\n />\n <span\n v-if=\"!inlinePrompt && (inactiveIcon || inactiveText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--left',\n !checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"inactiveIcon\"><component :is=\"inactiveIcon\" /></el-icon>\n <span v-if=\"!inactiveIcon && inactiveText\" :aria-hidden=\"checked\">{{\n inactiveText\n }}</span>\n </span>\n <span\n ref=\"core\"\n class=\"el-switch__core\"\n :style=\"{ width: (width || 40) + 'px' }\"\n >\n <div v-if=\"inlinePrompt\" class=\"el-switch__inner\">\n <template v-if=\"activeIcon || inactiveIcon\">\n <el-icon\n v-if=\"activeIcon\"\n class=\"is-icon\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"activeIcon\" />\n </el-icon>\n <el-icon\n v-if=\"inactiveIcon\"\n class=\"is-icon\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"inactiveIcon\" />\n </el-icon>\n </template>\n <template v-else-if=\"activeText || inactiveIcon\">\n <span\n v-if=\"activeText\"\n class=\"is-text\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"!checked\"\n >\n {{ activeText.substr(0, 1) }}\n </span>\n <span\n v-if=\"inactiveText\"\n class=\"is-text\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"checked\"\n >\n {{ inactiveText.substr(0, 1) }}\n </span>\n </template>\n </div>\n <div class=\"el-switch__action\">\n <el-icon v-if=\"loading\" class=\"is-loading\"><loading /></el-icon>\n </div>\n </span>\n <span\n v-if=\"!inlinePrompt && (activeIcon || activeText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--right',\n checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"activeIcon\"><component :is=\"activeIcon\" /></el-icon>\n <span v-if=\"!activeIcon && activeText\" :aria-hidden=\"!checked\">{{\n activeText\n }}</span>\n </span>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, computed, onMounted, ref, nextTick, watch } from 'vue'\nimport { isPromise } from '@vue/shared'\nimport { isBool } from '@element-plus/utils/util'\nimport { throwError, debugWarn } from '@element-plus/utils/error'\nimport ElIcon from '@element-plus/components/icon'\nimport { Loading } from '@element-plus/icons-vue'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { useDisabled, useFormItem } from '@element-plus/hooks'\nimport { switchProps, switchEmits } from './switch'\n\nconst COMPONENT_NAME = 'ElSwitch'\n\nexport default defineComponent({\n name: COMPONENT_NAME,\n components: { ElIcon, Loading },\n\n props: switchProps,\n emits: switchEmits,\n\n setup(props, { emit }) {\n const { formItem } = useFormItem()\n const switchDisabled = useDisabled(computed(() => props.loading))\n\n const isModelValue = ref(props.modelValue !== false)\n const input = ref<HTMLInputElement>()\n const core = ref<HTMLSpanElement>()\n\n watch(\n () => props.modelValue,\n () => {\n isModelValue.value = true\n }\n )\n\n watch(\n () => props.value,\n () => {\n isModelValue.value = false\n }\n )\n\n const actualValue = computed(() => {\n return isModelValue.value ? props.modelValue : props.value\n })\n\n const checked = computed(() => actualValue.value === props.activeValue)\n\n if (![props.activeValue, props.inactiveValue].includes(actualValue.value)) {\n emit(UPDATE_MODEL_EVENT, props.inactiveValue)\n emit(CHANGE_EVENT, props.inactiveValue)\n emit(INPUT_EVENT, props.inactiveValue)\n }\n\n watch(checked, () => {\n input.value!.checked = checked.value\n\n if (props.activeColor || props.inactiveColor) {\n setBackgroundColor()\n }\n\n if (props.validateEvent) {\n formItem?.validate?.('change')\n }\n })\n\n const handleChange = (): void => {\n const val = checked.value ? props.inactiveValue : props.activeValue\n emit(UPDATE_MODEL_EVENT, val)\n emit(CHANGE_EVENT, val)\n emit(INPUT_EVENT, val)\n nextTick(() => {\n input.value!.checked = checked.value\n })\n }\n\n const switchValue = (): void => {\n if (switchDisabled.value) return\n\n const { beforeChange } = props\n if (!beforeChange) {\n handleChange()\n return\n }\n\n const shouldChange = beforeChange()\n\n const isExpectType = [isPromise(shouldChange), isBool(shouldChange)].some(\n (i) => i\n )\n if (!isExpectType) {\n throwError(\n COMPONENT_NAME,\n 'beforeChange must return type `Promise<boolean>` or `boolean`'\n )\n }\n\n if (isPromise(shouldChange)) {\n shouldChange\n .then((result) => {\n if (result) {\n handleChange()\n }\n })\n .catch((e) => {\n debugWarn(COMPONENT_NAME, `some error occurred: ${e}`)\n })\n } else if (shouldChange) {\n handleChange()\n }\n }\n\n const setBackgroundColor = (): void => {\n const newColor = checked.value ? props.activeColor : props.inactiveColor\n const coreEl = core.value\n if (props.borderColor) coreEl!.style.borderColor = props.borderColor\n else if (!props.borderColor) coreEl!.style.borderColor = newColor\n coreEl!.style.backgroundColor = newColor\n ;(coreEl!.children[0] as HTMLDivElement).style.color = newColor\n }\n\n const focus = (): void => {\n input.value?.focus?.()\n }\n\n onMounted(() => {\n if (props.activeColor || props.inactiveColor || props.borderColor) {\n setBackgroundColor()\n }\n\n input.value!.checked = checked.value\n })\n\n return {\n input,\n core,\n switchDisabled,\n checked,\n handleChange,\n switchValue,\n focus,\n }\n },\n})\n</script>\n"],"names":["_createElementVNode","_normalizeClass","_createBlock"],"mappings":";;;;;;;;EAuC+B;;;;;;;;;;;wBAtC7B;IACE;IAEA;;IAECA;;;;MAIE,IAAI;MACL;MACA;MACA;MACC,eAAU;MACV,8BAAuB;MACvB,iCAA0B;;qGAEN;MACpB;;;;;;;;;;;WAUc;;;;;;;;;;;;;;;;;WAMX;;;;;yBAIJ;;;mBAGYC,cAAU;;;4BACXC;;;;;;;;;;;;;;;;;;;;iBAaY;;;;;;yCAKF;;;;;;0BAMf;;;;;;;;;SASW;;;cAAS;;;;;;;;;"}
1
+ {"version":3,"file":"switch.vue_vue_type_template_id_538fbc85_lang.mjs","sources":["../../../../../../packages/components/switch/src/switch.vue?vue&type=template&id=538fbc85&lang.js"],"sourcesContent":["<template>\n <div\n :class=\"switchKls\"\n role=\"switch\"\n :aria-checked=\"checked\"\n :aria-disabled=\"switchDisabled\"\n @click.prevent=\"switchValue\"\n >\n <input\n :id=\"id\"\n ref=\"input\"\n class=\"el-switch__input\"\n type=\"checkbox\"\n :name=\"name\"\n :true-value=\"activeValue\"\n :false-value=\"inactiveValue\"\n :disabled=\"switchDisabled\"\n @change=\"handleChange\"\n @keydown.enter=\"switchValue\"\n />\n <span\n v-if=\"!inlinePrompt && (inactiveIcon || inactiveText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--left',\n !checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"inactiveIcon\"><component :is=\"inactiveIcon\" /></el-icon>\n <span v-if=\"!inactiveIcon && inactiveText\" :aria-hidden=\"checked\">{{\n inactiveText\n }}</span>\n </span>\n <span\n ref=\"core\"\n class=\"el-switch__core\"\n :style=\"{ width: (width || 40) + 'px' }\"\n >\n <div v-if=\"inlinePrompt\" class=\"el-switch__inner\">\n <template v-if=\"activeIcon || inactiveIcon\">\n <el-icon\n v-if=\"activeIcon\"\n class=\"is-icon\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"activeIcon\" />\n </el-icon>\n <el-icon\n v-if=\"inactiveIcon\"\n class=\"is-icon\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n >\n <component :is=\"inactiveIcon\" />\n </el-icon>\n </template>\n <template v-else-if=\"activeText || inactiveIcon\">\n <span\n v-if=\"activeText\"\n class=\"is-text\"\n :class=\"checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"!checked\"\n >\n {{ activeText.substr(0, 1) }}\n </span>\n <span\n v-if=\"inactiveText\"\n class=\"is-text\"\n :class=\"!checked ? 'is-show' : 'is-hide'\"\n :aria-hidden=\"checked\"\n >\n {{ inactiveText.substr(0, 1) }}\n </span>\n </template>\n </div>\n <div class=\"el-switch__action\">\n <el-icon v-if=\"loading\" class=\"is-loading\"><loading /></el-icon>\n </div>\n </span>\n <span\n v-if=\"!inlinePrompt && (activeIcon || activeText)\"\n :class=\"[\n 'el-switch__label',\n 'el-switch__label--right',\n checked ? 'is-active' : '',\n ]\"\n >\n <el-icon v-if=\"activeIcon\"><component :is=\"activeIcon\" /></el-icon>\n <span v-if=\"!activeIcon && activeText\" :aria-hidden=\"!checked\">{{\n activeText\n }}</span>\n </span>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, computed, onMounted, ref, nextTick, watch } from 'vue'\nimport { isPromise } from '@vue/shared'\nimport { isBool } from '@element-plus/utils/util'\nimport { throwError, debugWarn } from '@element-plus/utils/error'\nimport ElIcon from '@element-plus/components/icon'\nimport { Loading } from '@element-plus/icons-vue'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport { useDisabled, useFormItem, useSize } from '@element-plus/hooks'\nimport { switchProps, switchEmits } from './switch'\n\nconst COMPONENT_NAME = 'ElSwitch'\n\nexport default defineComponent({\n name: COMPONENT_NAME,\n components: { ElIcon, Loading },\n\n props: switchProps,\n emits: switchEmits,\n\n setup(props, { emit }) {\n const { formItem } = useFormItem()\n const switchDisabled = useDisabled(computed(() => props.loading))\n\n const switchSize = useSize()\n const isModelValue = ref(props.modelValue !== false)\n const input = ref<HTMLInputElement>()\n const core = ref<HTMLSpanElement>()\n\n const prefix = 'el-switch'\n const switchKls = computed(() => [\n prefix,\n `${prefix}--${switchSize.value}`,\n switchDisabled.value ? 'is-disabled' : '',\n checked.value ? 'is-checked' : '',\n ])\n\n watch(\n () => props.modelValue,\n () => {\n isModelValue.value = true\n }\n )\n\n watch(\n () => props.value,\n () => {\n isModelValue.value = false\n }\n )\n\n const actualValue = computed(() => {\n return isModelValue.value ? props.modelValue : props.value\n })\n\n const checked = computed(() => actualValue.value === props.activeValue)\n\n if (![props.activeValue, props.inactiveValue].includes(actualValue.value)) {\n emit(UPDATE_MODEL_EVENT, props.inactiveValue)\n emit(CHANGE_EVENT, props.inactiveValue)\n emit(INPUT_EVENT, props.inactiveValue)\n }\n\n watch(checked, () => {\n input.value!.checked = checked.value\n\n if (props.activeColor || props.inactiveColor) {\n setBackgroundColor()\n }\n\n if (props.validateEvent) {\n formItem?.validate?.('change')\n }\n })\n\n const handleChange = (): void => {\n const val = checked.value ? props.inactiveValue : props.activeValue\n emit(UPDATE_MODEL_EVENT, val)\n emit(CHANGE_EVENT, val)\n emit(INPUT_EVENT, val)\n nextTick(() => {\n input.value!.checked = checked.value\n })\n }\n\n const switchValue = (): void => {\n if (switchDisabled.value) return\n\n const { beforeChange } = props\n if (!beforeChange) {\n handleChange()\n return\n }\n\n const shouldChange = beforeChange()\n\n const isExpectType = [isPromise(shouldChange), isBool(shouldChange)].some(\n (i) => i\n )\n if (!isExpectType) {\n throwError(\n COMPONENT_NAME,\n 'beforeChange must return type `Promise<boolean>` or `boolean`'\n )\n }\n\n if (isPromise(shouldChange)) {\n shouldChange\n .then((result) => {\n if (result) {\n handleChange()\n }\n })\n .catch((e) => {\n debugWarn(COMPONENT_NAME, `some error occurred: ${e}`)\n })\n } else if (shouldChange) {\n handleChange()\n }\n }\n\n const setBackgroundColor = (): void => {\n const newColor = checked.value ? props.activeColor : props.inactiveColor\n const coreEl = core.value\n if (props.borderColor) coreEl!.style.borderColor = props.borderColor\n else if (!props.borderColor) coreEl!.style.borderColor = newColor\n coreEl!.style.backgroundColor = newColor\n ;(coreEl!.children[0] as HTMLDivElement).style.color = newColor\n }\n\n const focus = (): void => {\n input.value?.focus?.()\n }\n\n onMounted(() => {\n if (props.activeColor || props.inactiveColor || props.borderColor) {\n setBackgroundColor()\n }\n\n input.value!.checked = checked.value\n })\n\n return {\n input,\n core,\n switchDisabled,\n checked,\n switchKls,\n handleChange,\n switchValue,\n focus,\n }\n },\n})\n</script>\n"],"names":["_createElementVNode","_normalizeClass","_createBlock"],"mappings":";;;;;;;;EAsC+B;;;;;;;;;;;wBArC7B;IACG;IACD;;IAECA;;;;MAIE,IAAI;MACL;MACA;MACA;MACC,eAAU;MACV,8BAAuB;MACvB,iCAA0B;;qGAEN;MACpB;;;;;;;;;;;WAUc;;;;;;;;;;;;;;;;;WAMX;;;;;yBAIJ;;;mBAGYC,cAAU;;;4BACXC;;;;;;;;;;;;;;;;;;;;iBAaY;;;;;;yCAKF;;;;;;0BAMf;;;;;;;;;SASW;;;cAAS;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter-panel.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/table/src/filter-panel.vue"],"sourcesContent":["<template>\n <el-tooltip\n ref=\"tooltip\"\n v-model:visible=\"tooltipVisible\"\n :offset=\"0\"\n :placement=\"placement\"\n :show-arrow=\"false\"\n :stop-popper-mouse-event=\"false\"\n append-to-body\n effect=\"light\"\n pure\n popper-class=\"el-table-filter\"\n >\n <template #content>\n <div v-if=\"multiple\">\n <div class=\"el-table-filter__content\">\n <el-scrollbar wrap-class=\"el-table-filter__wrap\">\n <el-checkbox-group\n v-model=\"filteredValue\"\n class=\"el-table-filter__checkbox-group\"\n >\n <el-checkbox\n v-for=\"filter in filters\"\n :key=\"filter.value\"\n :label=\"filter.value\"\n >\n {{ filter.text }}\n </el-checkbox>\n </el-checkbox-group>\n </el-scrollbar>\n </div>\n <div class=\"el-table-filter__bottom\">\n <button\n :class=\"{ 'is-disabled': filteredValue.length === 0 }\"\n :disabled=\"filteredValue.length === 0\"\n type=\"button\"\n @click=\"handleConfirm\"\n >\n {{ t('el.table.confirmFilter') }}\n </button>\n <button type=\"button\" @click=\"handleReset\">\n {{ t('el.table.resetFilter') }}\n </button>\n </div>\n </div>\n <ul v-else class=\"el-table-filter__list\">\n <li\n :class=\"{\n 'is-active': filterValue === undefined || filterValue === null,\n }\"\n class=\"el-table-filter__list-item\"\n @click=\"handleSelect(null)\"\n >\n {{ t('el.table.clearFilter') }}\n </li>\n <li\n v-for=\"filter in filters\"\n :key=\"filter.value\"\n :class=\"{ 'is-active': isActive(filter) }\"\n :label=\"filter.value\"\n class=\"el-table-filter__list-item\"\n @click=\"handleSelect(filter.value)\"\n >\n {{ filter.text }}\n </li>\n </ul>\n </template>\n <template #default>\n <span\n v-click-outside:[popperPaneRef]=\"hideFilterPanel\"\n class=\"el-table__column-filter-trigger el-none-outline\"\n @click=\"showFilterPanel\"\n >\n <el-icon>\n <arrow-up v-if=\"column.filterOpened\" />\n <arrow-down v-else />\n </el-icon>\n </span>\n </template>\n </el-tooltip>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, ref, computed, getCurrentInstance, watch } from 'vue'\nimport ElCheckbox from '@element-plus/components/checkbox'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { ArrowDown, ArrowUp } from '@element-plus/icons-vue'\nimport { ClickOutside } from '@element-plus/directives'\nimport { useLocale } from '@element-plus/hooks'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport type { Placement } from '@element-plus/components/popper'\n\nimport type { WritableComputedRef, PropType } from 'vue'\nimport type { TableColumnCtx } from './table-column/defaults'\nimport type { TableHeader } from './table-header'\nimport type { Store } from './store'\n\nconst { CheckboxGroup: ElCheckboxGroup } = ElCheckbox\n\nexport default defineComponent({\n name: 'ElTableFilterPanel',\n components: {\n ElCheckbox,\n ElCheckboxGroup,\n ElScrollbar,\n ElTooltip,\n ElIcon,\n ArrowDown,\n ArrowUp,\n },\n directives: { ClickOutside },\n props: {\n placement: {\n type: String as PropType<Placement>,\n default: 'bottom-start',\n },\n store: {\n type: Object as PropType<Store<unknown>>,\n },\n column: {\n type: Object as PropType<TableColumnCtx<unknown>>,\n },\n upDataColumn: {\n type: Function,\n },\n },\n setup(props) {\n const instance = getCurrentInstance()\n const { t } = useLocale()\n const parent = instance.parent as TableHeader\n if (!parent.filterPanels.value[props.column.id]) {\n parent.filterPanels.value[props.column.id] = instance\n }\n const tooltipVisible = ref(false)\n const tooltip = ref<InstanceType<typeof ElTooltip> | null>(null)\n const filters = computed(() => {\n return props.column && props.column.filters\n })\n const filterValue = computed({\n get: () => (props.column.filteredValue || [])[0],\n set: (value: string) => {\n if (filteredValue.value) {\n if (typeof value !== 'undefined' && value !== null) {\n filteredValue.value.splice(0, 1, value)\n } else {\n filteredValue.value.splice(0, 1)\n }\n }\n },\n })\n const filteredValue: WritableComputedRef<unknown[]> = computed({\n get() {\n if (props.column) {\n return props.column.filteredValue || []\n }\n return []\n },\n set(value: unknown[]) {\n if (props.column) {\n props.upDataColumn('filteredValue', value)\n }\n },\n })\n const multiple = computed(() => {\n if (props.column) {\n return props.column.filterMultiple\n }\n return true\n })\n const isActive = (filter) => {\n return filter.value === filterValue.value\n }\n const hidden = () => {\n tooltipVisible.value = false\n }\n const showFilterPanel = (e: MouseEvent) => {\n e.stopPropagation()\n tooltipVisible.value = !tooltipVisible.value\n }\n const hideFilterPanel = () => {\n tooltipVisible.value = false\n }\n const handleConfirm = () => {\n confirmFilter(filteredValue.value)\n hidden()\n }\n const handleReset = () => {\n filteredValue.value = []\n confirmFilter(filteredValue.value)\n hidden()\n }\n const handleSelect = (_filterValue?: string) => {\n filterValue.value = _filterValue\n if (typeof _filterValue !== 'undefined' && _filterValue !== null) {\n confirmFilter(filteredValue.value)\n } else {\n confirmFilter([])\n }\n hidden()\n }\n const confirmFilter = (filteredValue: unknown[]) => {\n props.store.commit('filterChange', {\n column: props.column,\n values: filteredValue,\n })\n props.store.updateAllSelected()\n }\n watch(\n tooltipVisible,\n (value) => {\n // todo\n if (props.column) {\n props.upDataColumn('filterOpened', value)\n }\n },\n {\n immediate: true,\n }\n )\n\n const popperPaneRef = computed(() => {\n return tooltip.value?.popperRef?.contentRef\n })\n\n return {\n tooltipVisible,\n multiple,\n filteredValue,\n filterValue,\n filters,\n handleConfirm,\n handleReset,\n handleSelect,\n isActive,\n t,\n showFilterPanel,\n hideFilterPanel,\n popperPaneRef,\n tooltip,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;AA0FA,QAAQ,aAAa,iBAAiB,EAAE,GAAG,UAAU,CAAC;AACtD,aAAe,gBAAgB;;AAE/B,EAAE,UAAU,EAAE;AACd,IAAI,UAAU;AACd,IA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AAW,CAAC,KAAK,GAAG,YAAY,CAAC;MACjC,IAAI;;OAEH,MAAM;QACL,aAAa,CAAC,EAAE,EAAE;OACnB;MACD,MAAM;;IAER,MAAM,aAAa,GAAG,CAAC,cAAc,KAAK;MACxC,KAAK,CAAC,KAAK,CAAC,MAAM;cACV,OAAO,CAAC,MAAM;QACpB,MAAM,EAAE,cAAc;QACtB,CAAC;WACE,CAAC,KAAK,CAAC;MACZ;SACG,CAAC;;QAEF,KAAK,CAAC,YAAY,CAAC,gBAAgB,KAAK,CAAC,CAAC;OAC3C;;iBAEU,IAAI;MACf,CAAC;UACG,aAAa,GAAG,QAAQ,CAAC;;MAE7B;MACA,CAAC;WACI;;cAEG;mBACK;;MAEb;MACA;iBACW;MACX;;;MAGA,eAAe;MACf,eAAe;;;KAGhB,CAAC;;;;;;"}
1
+ {"version":3,"file":"filter-panel.vue_vue_type_script_lang.mjs","sources":["../../../../../../packages/components/table/src/filter-panel.vue"],"sourcesContent":["<template>\n <el-tooltip\n ref=\"tooltip\"\n v-model:visible=\"tooltipVisible\"\n :offset=\"0\"\n :placement=\"placement\"\n :show-arrow=\"false\"\n :stop-popper-mouse-event=\"false\"\n append-to-body\n effect=\"light\"\n pure\n popper-class=\"el-table-filter\"\n persistent\n >\n <template #content>\n <div v-if=\"multiple\">\n <div class=\"el-table-filter__content\">\n <el-scrollbar wrap-class=\"el-table-filter__wrap\">\n <el-checkbox-group\n v-model=\"filteredValue\"\n class=\"el-table-filter__checkbox-group\"\n >\n <el-checkbox\n v-for=\"filter in filters\"\n :key=\"filter.value\"\n :label=\"filter.value\"\n >\n {{ filter.text }}\n </el-checkbox>\n </el-checkbox-group>\n </el-scrollbar>\n </div>\n <div class=\"el-table-filter__bottom\">\n <button\n :class=\"{ 'is-disabled': filteredValue.length === 0 }\"\n :disabled=\"filteredValue.length === 0\"\n type=\"button\"\n @click=\"handleConfirm\"\n >\n {{ t('el.table.confirmFilter') }}\n </button>\n <button type=\"button\" @click=\"handleReset\">\n {{ t('el.table.resetFilter') }}\n </button>\n </div>\n </div>\n <ul v-else class=\"el-table-filter__list\">\n <li\n :class=\"{\n 'is-active': filterValue === undefined || filterValue === null,\n }\"\n class=\"el-table-filter__list-item\"\n @click=\"handleSelect(null)\"\n >\n {{ t('el.table.clearFilter') }}\n </li>\n <li\n v-for=\"filter in filters\"\n :key=\"filter.value\"\n :class=\"{ 'is-active': isActive(filter) }\"\n :label=\"filter.value\"\n class=\"el-table-filter__list-item\"\n @click=\"handleSelect(filter.value)\"\n >\n {{ filter.text }}\n </li>\n </ul>\n </template>\n <template #default>\n <span\n v-click-outside:[popperPaneRef]=\"hideFilterPanel\"\n class=\"el-table__column-filter-trigger el-none-outline\"\n @click=\"showFilterPanel\"\n >\n <el-icon>\n <arrow-up v-if=\"column.filterOpened\" />\n <arrow-down v-else />\n </el-icon>\n </span>\n </template>\n </el-tooltip>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, ref, computed, getCurrentInstance, watch } from 'vue'\nimport ElCheckbox from '@element-plus/components/checkbox'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { ArrowDown, ArrowUp } from '@element-plus/icons-vue'\nimport { ClickOutside } from '@element-plus/directives'\nimport { useLocale } from '@element-plus/hooks'\nimport ElTooltip from '@element-plus/components/tooltip'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport type { Placement } from '@element-plus/components/popper'\n\nimport type { WritableComputedRef, PropType } from 'vue'\nimport type { TableColumnCtx } from './table-column/defaults'\nimport type { TableHeader } from './table-header'\nimport type { Store } from './store'\n\nconst { CheckboxGroup: ElCheckboxGroup } = ElCheckbox\n\nexport default defineComponent({\n name: 'ElTableFilterPanel',\n components: {\n ElCheckbox,\n ElCheckboxGroup,\n ElScrollbar,\n ElTooltip,\n ElIcon,\n ArrowDown,\n ArrowUp,\n },\n directives: { ClickOutside },\n props: {\n placement: {\n type: String as PropType<Placement>,\n default: 'bottom-start',\n },\n store: {\n type: Object as PropType<Store<unknown>>,\n },\n column: {\n type: Object as PropType<TableColumnCtx<unknown>>,\n },\n upDataColumn: {\n type: Function,\n },\n },\n setup(props) {\n const instance = getCurrentInstance()\n const { t } = useLocale()\n const parent = instance.parent as TableHeader\n if (!parent.filterPanels.value[props.column.id]) {\n parent.filterPanels.value[props.column.id] = instance\n }\n const tooltipVisible = ref(false)\n const tooltip = ref<InstanceType<typeof ElTooltip> | null>(null)\n const filters = computed(() => {\n return props.column && props.column.filters\n })\n const filterValue = computed({\n get: () => (props.column.filteredValue || [])[0],\n set: (value: string) => {\n if (filteredValue.value) {\n if (typeof value !== 'undefined' && value !== null) {\n filteredValue.value.splice(0, 1, value)\n } else {\n filteredValue.value.splice(0, 1)\n }\n }\n },\n })\n const filteredValue: WritableComputedRef<unknown[]> = computed({\n get() {\n if (props.column) {\n return props.column.filteredValue || []\n }\n return []\n },\n set(value: unknown[]) {\n if (props.column) {\n props.upDataColumn('filteredValue', value)\n }\n },\n })\n const multiple = computed(() => {\n if (props.column) {\n return props.column.filterMultiple\n }\n return true\n })\n const isActive = (filter) => {\n return filter.value === filterValue.value\n }\n const hidden = () => {\n tooltipVisible.value = false\n }\n const showFilterPanel = (e: MouseEvent) => {\n e.stopPropagation()\n tooltipVisible.value = !tooltipVisible.value\n }\n const hideFilterPanel = () => {\n tooltipVisible.value = false\n }\n const handleConfirm = () => {\n confirmFilter(filteredValue.value)\n hidden()\n }\n const handleReset = () => {\n filteredValue.value = []\n confirmFilter(filteredValue.value)\n hidden()\n }\n const handleSelect = (_filterValue?: string) => {\n filterValue.value = _filterValue\n if (typeof _filterValue !== 'undefined' && _filterValue !== null) {\n confirmFilter(filteredValue.value)\n } else {\n confirmFilter([])\n }\n hidden()\n }\n const confirmFilter = (filteredValue: unknown[]) => {\n props.store.commit('filterChange', {\n column: props.column,\n values: filteredValue,\n })\n props.store.updateAllSelected()\n }\n watch(\n tooltipVisible,\n (value) => {\n // todo\n if (props.column) {\n props.upDataColumn('filterOpened', value)\n }\n },\n {\n immediate: true,\n }\n )\n\n const popperPaneRef = computed(() => {\n return tooltip.value?.popperRef?.contentRef\n })\n\n return {\n tooltipVisible,\n multiple,\n filteredValue,\n filterValue,\n filters,\n handleConfirm,\n handleReset,\n handleSelect,\n isActive,\n t,\n showFilterPanel,\n hideFilterPanel,\n popperPaneRef,\n tooltip,\n }\n },\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;AA2FA,QAAQ,aAAa,iBAAiB,EAAE,GAAG,UAAU,CAAC;AACtD,aAAe,gBAAgB;;AAE/B,EAAE,UAAU,EAAE;AACd,IAAI,UAAU;AACd,IAAI,eAAe;AACnB,IAAI,WAAW;;AAEf,IAAI,MAAM;;AAEV,IAAI,OAAO;GACR;EACD,UAAU,EAAE;OACP,EAAE;IACL,SAAS,EAAE;MACT,IAAI,EAAE;MACN,OAAO;KACR;IACD,KAAK,EAAE;MACL,IAAI;;IAEN,MAAM,EAAE;MACN;KACD;gBACW;MACV,IAAI,EAAE,QAAQ;KACf;;OAEE,CAAC,KAAK,EAAE;IACX;IACA,MAAM,EAAE;UACF,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B;MACE,MAAM,CAAC;;IAET;;IAEA,MAAM;MACJ,OAAO,MAAM,MAAM,IAAI,KAAK,CAAC;KAC9B,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,QAAQ,CAAC;SACxB,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,GAAG;MAC/C,GAAG,EAAE,CAAC,KAAK,KAAK;;UAEZ,IAAI,OAAO,UAAU;YACnB,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC;WACzC;0BACe,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;;OAGtC;MACD,CAAC;uBACgB,GAAG;;YAEd,KAAK,CAAC,MAAM,EAAE;UAChB,OAAO;;;;MAIX;;UAEI,KAAK,CAAC,YAAY,CAAC,eAAe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