vue-devui 1.0.0-alpha.5 → 1.0.0-beta.11

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 (344) hide show
  1. package/README.md +31 -36
  2. package/accordion/index.d.ts +7 -0
  3. package/accordion/index.es.js +508 -1
  4. package/accordion/index.umd.js +1 -1
  5. package/accordion/style.css +1 -1
  6. package/alert/index.d.ts +7 -0
  7. package/alert/index.es.js +175 -1
  8. package/alert/index.umd.js +1 -1
  9. package/alert/style.css +1 -1
  10. package/anchor/index.d.ts +7 -0
  11. package/anchor/index.es.js +263 -1
  12. package/anchor/index.umd.js +1 -1
  13. package/avatar/index.d.ts +7 -0
  14. package/avatar/index.es.js +301 -1
  15. package/avatar/index.umd.js +1 -1
  16. package/back-top/index.d.ts +7 -0
  17. package/back-top/index.es.js +128 -0
  18. package/back-top/index.umd.js +1 -0
  19. package/back-top/package.json +7 -0
  20. package/back-top/style.css +1 -0
  21. package/badge/index.d.ts +7 -0
  22. package/badge/index.es.js +95 -1
  23. package/badge/index.umd.js +1 -1
  24. package/breadcrumb/index.d.ts +7 -0
  25. package/breadcrumb/index.es.js +127 -1
  26. package/breadcrumb/index.umd.js +1 -1
  27. package/button/index.d.ts +7 -0
  28. package/button/index.es.js +392 -1
  29. package/button/index.umd.js +1 -1
  30. package/button/style.css +1 -1
  31. package/card/index.d.ts +7 -0
  32. package/card/index.es.js +61 -1
  33. package/card/index.umd.js +1 -1
  34. package/carousel/index.d.ts +7 -0
  35. package/carousel/index.es.js +329 -1
  36. package/carousel/index.umd.js +1 -1
  37. package/cascader/index.d.ts +7 -0
  38. package/cascader/index.es.js +1343 -1
  39. package/cascader/index.umd.js +1 -1
  40. package/cascader/style.css +1 -1
  41. package/checkbox/index.d.ts +7 -0
  42. package/checkbox/index.es.js +377 -1
  43. package/checkbox/index.umd.js +1 -1
  44. package/comment/index.d.ts +7 -0
  45. package/comment/index.es.js +85 -0
  46. package/comment/index.umd.js +1 -0
  47. package/comment/package.json +7 -0
  48. package/comment/style.css +1 -0
  49. package/countdown/index.d.ts +7 -0
  50. package/countdown/index.es.js +176 -0
  51. package/countdown/index.umd.js +1 -0
  52. package/countdown/package.json +7 -0
  53. package/countdown/style.css +1 -0
  54. package/date-picker/index.d.ts +7 -0
  55. package/date-picker/index.es.js +1172 -1
  56. package/date-picker/index.umd.js +1 -1
  57. package/date-picker/style.css +1 -1
  58. package/dragdrop/index.d.ts +7 -0
  59. package/dragdrop/index.es.js +32 -0
  60. package/dragdrop/index.umd.js +1 -0
  61. package/dragdrop/package.json +7 -0
  62. package/drawer/index.d.ts +7 -0
  63. package/drawer/index.es.js +287 -0
  64. package/drawer/index.umd.js +1 -0
  65. package/drawer/package.json +7 -0
  66. package/drawer/style.css +1 -0
  67. package/dropdown/index.d.ts +7 -0
  68. package/dropdown/index.es.js +527 -0
  69. package/dropdown/index.umd.js +1 -0
  70. package/dropdown/package.json +7 -0
  71. package/dropdown/style.css +1 -0
  72. package/editable-select/index.d.ts +7 -0
  73. package/editable-select/index.es.js +5857 -1
  74. package/editable-select/index.umd.js +27 -1
  75. package/editable-select/style.css +1 -1
  76. package/form/index.d.ts +7 -0
  77. package/form/index.es.js +2244 -0
  78. package/form/index.umd.js +1 -0
  79. package/form/package.json +7 -0
  80. package/form/style.css +1 -0
  81. package/fullscreen/index.d.ts +7 -0
  82. package/fullscreen/index.es.js +163 -1
  83. package/fullscreen/index.umd.js +1 -1
  84. package/gantt/index.d.ts +7 -0
  85. package/gantt/index.es.js +535 -0
  86. package/gantt/index.umd.js +1 -0
  87. package/gantt/package.json +7 -0
  88. package/gantt/style.css +1 -0
  89. package/grid/index.d.ts +7 -0
  90. package/grid/index.es.js +269 -0
  91. package/grid/index.umd.js +1 -0
  92. package/grid/package.json +7 -0
  93. package/grid/style.css +1 -0
  94. package/icon/index.d.ts +7 -0
  95. package/icon/index.es.js +75 -1
  96. package/icon/index.umd.js +1 -1
  97. package/image-preview/index.d.ts +7 -0
  98. package/image-preview/index.es.js +480 -1
  99. package/image-preview/index.umd.js +1 -1
  100. package/image-preview/style.css +1 -1
  101. package/index.d.ts +7 -0
  102. package/input/index.d.ts +7 -0
  103. package/input/index.es.js +190 -1
  104. package/input/index.umd.js +1 -1
  105. package/input-icon/index.d.ts +7 -0
  106. package/input-icon/index.es.js +332 -0
  107. package/input-icon/index.umd.js +1 -0
  108. package/input-icon/package.json +7 -0
  109. package/input-icon/style.css +1 -0
  110. package/input-number/index.d.ts +7 -0
  111. package/input-number/index.es.js +240 -1
  112. package/input-number/index.umd.js +1 -1
  113. package/layout/index.d.ts +7 -0
  114. package/layout/index.es.js +100 -0
  115. package/layout/index.umd.js +1 -0
  116. package/layout/package.json +7 -0
  117. package/layout/style.css +1 -0
  118. package/loading/index.d.ts +7 -0
  119. package/loading/index.es.js +256 -1
  120. package/loading/index.umd.js +1 -1
  121. package/modal/index.d.ts +7 -0
  122. package/modal/index.es.js +1225 -1
  123. package/modal/index.umd.js +1 -1
  124. package/modal/style.css +1 -1
  125. package/nav-sprite/index.d.ts +7 -0
  126. package/nav-sprite/index.es.js +742 -0
  127. package/nav-sprite/index.umd.js +1 -0
  128. package/nav-sprite/package.json +7 -0
  129. package/nuxt/components/Accordion.js +3 -0
  130. package/nuxt/components/Alert.js +3 -0
  131. package/nuxt/components/Anchor.js +3 -0
  132. package/nuxt/components/Aside.js +3 -0
  133. package/nuxt/components/Avatar.js +3 -0
  134. package/nuxt/components/BackTop.js +3 -0
  135. package/nuxt/components/Badge.js +3 -0
  136. package/nuxt/components/Breadcrumb.js +3 -0
  137. package/nuxt/components/Button.js +3 -0
  138. package/nuxt/components/Card.js +3 -0
  139. package/nuxt/components/Carousel.js +3 -0
  140. package/nuxt/components/Cascader.js +3 -0
  141. package/nuxt/components/Checkbox.js +3 -0
  142. package/nuxt/components/Col.js +3 -0
  143. package/nuxt/components/Column.js +3 -0
  144. package/nuxt/components/Comment.js +3 -0
  145. package/nuxt/components/Content.js +3 -0
  146. package/nuxt/components/Countdown.js +3 -0
  147. package/nuxt/components/DatePicker.js +3 -0
  148. package/nuxt/components/Drawer.js +3 -0
  149. package/nuxt/components/Dropdown.js +3 -0
  150. package/nuxt/components/EditableSelect.js +3 -0
  151. package/nuxt/components/FixedOverlay.js +3 -0
  152. package/nuxt/components/FlexibleOverlay.js +3 -0
  153. package/nuxt/components/Footer.js +3 -0
  154. package/nuxt/components/Form.js +3 -0
  155. package/nuxt/components/FormControl.js +3 -0
  156. package/nuxt/components/FormItem.js +3 -0
  157. package/nuxt/components/FormLabel.js +3 -0
  158. package/nuxt/components/FormOperation.js +3 -0
  159. package/nuxt/components/Fullscreen.js +3 -0
  160. package/nuxt/components/Gantt.js +3 -0
  161. package/nuxt/components/Header.js +3 -0
  162. package/nuxt/components/Icon.js +2 -0
  163. package/nuxt/components/ImagePreviewService.js +3 -0
  164. package/nuxt/components/Input.js +3 -0
  165. package/nuxt/components/InputIcon.js +3 -0
  166. package/nuxt/components/InputNumber.js +3 -0
  167. package/nuxt/components/Layout.js +3 -0
  168. package/nuxt/components/Loading.js +3 -0
  169. package/nuxt/components/LoadingService.js +3 -0
  170. package/nuxt/components/Modal.js +3 -0
  171. package/nuxt/components/NavSprite.js +2 -0
  172. package/nuxt/components/Pagination.js +3 -0
  173. package/nuxt/components/Panel.js +3 -0
  174. package/nuxt/components/Popover.js +3 -0
  175. package/nuxt/components/Progress.js +3 -0
  176. package/nuxt/components/QuadrantDiagram.js +3 -0
  177. package/nuxt/components/Radio.js +3 -0
  178. package/nuxt/components/RadioGroup.js +3 -0
  179. package/nuxt/components/Rate.js +3 -0
  180. package/nuxt/components/ReadTip.js +3 -0
  181. package/nuxt/components/Result.js +3 -0
  182. package/nuxt/components/Row.js +3 -0
  183. package/nuxt/components/Search.js +3 -0
  184. package/nuxt/components/Select.js +3 -0
  185. package/nuxt/components/Skeleton.js +3 -0
  186. package/nuxt/components/SkeletonItem.js +3 -0
  187. package/nuxt/components/Slider.js +3 -0
  188. package/nuxt/components/Splitter.js +3 -0
  189. package/nuxt/components/Statistic.js +3 -0
  190. package/nuxt/components/Status.js +3 -0
  191. package/nuxt/components/StepsGuide.js +3 -0
  192. package/nuxt/components/StickSlider.js +3 -0
  193. package/nuxt/components/Sticky.js +2 -0
  194. package/nuxt/components/Switch.js +3 -0
  195. package/nuxt/components/Table.js +3 -0
  196. package/nuxt/components/Tabs.js +3 -0
  197. package/nuxt/components/Tag.js +3 -0
  198. package/nuxt/components/TagInput.js +3 -0
  199. package/nuxt/components/Textarea.js +3 -0
  200. package/nuxt/components/TimeAxis.js +3 -0
  201. package/nuxt/components/TimeAxisItem.js +3 -0
  202. package/nuxt/components/TimePicker.js +3 -0
  203. package/nuxt/components/Toast.js +3 -0
  204. package/nuxt/components/ToastService.js +3 -0
  205. package/nuxt/components/Tooltip.js +3 -0
  206. package/nuxt/components/Transfer.js +3 -0
  207. package/nuxt/components/Tree.js +3 -0
  208. package/nuxt/components/TreeSelect.js +3 -0
  209. package/nuxt/components/Upload.js +3 -0
  210. package/nuxt/components/buttonProps.js +3 -0
  211. package/nuxt/index.js +13 -0
  212. package/overlay/index.d.ts +7 -0
  213. package/overlay/index.es.js +368 -1
  214. package/overlay/index.umd.js +1 -1
  215. package/overlay/style.css +1 -1
  216. package/package.json +8 -34
  217. package/pagination/index.d.ts +7 -0
  218. package/pagination/index.es.js +642 -1
  219. package/pagination/index.umd.js +1 -1
  220. package/panel/index.d.ts +7 -0
  221. package/panel/index.es.js +205 -1
  222. package/panel/index.umd.js +1 -1
  223. package/panel/style.css +1 -1
  224. package/popover/index.d.ts +7 -0
  225. package/popover/index.es.js +236 -1
  226. package/popover/index.umd.js +1 -1
  227. package/progress/index.d.ts +7 -0
  228. package/progress/index.es.js +153 -1
  229. package/progress/index.umd.js +3 -1
  230. package/quadrant-diagram/index.d.ts +7 -0
  231. package/quadrant-diagram/index.es.js +489 -1
  232. package/quadrant-diagram/index.umd.js +1 -1
  233. package/radio/index.d.ts +7 -0
  234. package/radio/index.es.js +225 -1
  235. package/radio/index.umd.js +1 -1
  236. package/rate/index.d.ts +7 -0
  237. package/rate/index.es.js +220 -1
  238. package/rate/index.umd.js +1 -1
  239. package/read-tip/index.d.ts +7 -0
  240. package/read-tip/index.es.js +258 -0
  241. package/read-tip/index.umd.js +1 -0
  242. package/read-tip/package.json +7 -0
  243. package/read-tip/style.css +1 -0
  244. package/result/index.d.ts +7 -0
  245. package/result/index.es.js +119 -0
  246. package/result/index.umd.js +1 -0
  247. package/result/package.json +7 -0
  248. package/result/style.css +1 -0
  249. package/ripple/index.d.ts +7 -0
  250. package/ripple/index.es.js +181 -1
  251. package/ripple/index.umd.js +1 -1
  252. package/search/index.d.ts +7 -0
  253. package/search/index.es.js +543 -1
  254. package/search/index.umd.js +1 -1
  255. package/select/index.d.ts +7 -0
  256. package/select/index.es.js +706 -1
  257. package/select/index.umd.js +1 -1
  258. package/skeleton/index.d.ts +7 -0
  259. package/skeleton/index.es.js +297 -1
  260. package/skeleton/index.umd.js +1 -1
  261. package/skeleton/style.css +1 -1
  262. package/slider/index.d.ts +7 -0
  263. package/slider/index.es.js +199 -1
  264. package/slider/index.umd.js +1 -1
  265. package/slider/style.css +1 -1
  266. package/splitter/index.d.ts +7 -0
  267. package/splitter/index.es.js +636 -1
  268. package/splitter/index.umd.js +1 -1
  269. package/statistic/index.d.ts +7 -0
  270. package/statistic/index.es.js +280 -0
  271. package/statistic/index.umd.js +1 -0
  272. package/statistic/package.json +7 -0
  273. package/statistic/style.css +1 -0
  274. package/status/index.d.ts +7 -0
  275. package/status/index.es.js +42 -1
  276. package/status/index.umd.js +1 -1
  277. package/steps-guide/index.d.ts +7 -0
  278. package/steps-guide/index.es.js +239 -1
  279. package/steps-guide/index.umd.js +1 -1
  280. package/steps-guide/style.css +1 -1
  281. package/sticky/index.d.ts +7 -0
  282. package/sticky/index.es.js +197 -1
  283. package/sticky/index.umd.js +1 -1
  284. package/style.css +1 -1
  285. package/switch/index.d.ts +7 -0
  286. package/switch/index.es.js +100 -1
  287. package/switch/index.umd.js +1 -1
  288. package/switch/style.css +1 -1
  289. package/table/index.d.ts +7 -0
  290. package/table/index.es.js +1828 -1
  291. package/table/index.umd.js +1 -1
  292. package/table/style.css +1 -1
  293. package/tabs/index.d.ts +7 -0
  294. package/tabs/index.es.js +195 -1
  295. package/tabs/index.umd.js +1 -1
  296. package/tabs/style.css +1 -1
  297. package/tag/index.d.ts +7 -0
  298. package/tag/index.es.js +131 -0
  299. package/tag/index.umd.js +1 -0
  300. package/tag/package.json +7 -0
  301. package/tag/style.css +1 -0
  302. package/tag-input/index.d.ts +7 -0
  303. package/tag-input/index.es.js +329 -1
  304. package/tag-input/index.umd.js +1 -1
  305. package/textarea/index.d.ts +7 -0
  306. package/textarea/index.es.js +132 -0
  307. package/textarea/index.umd.js +1 -0
  308. package/textarea/package.json +7 -0
  309. package/textarea/style.css +1 -0
  310. package/time-axis/index.d.ts +7 -0
  311. package/time-axis/index.es.js +299 -0
  312. package/time-axis/index.umd.js +1 -0
  313. package/time-axis/package.json +7 -0
  314. package/time-axis/style.css +1 -0
  315. package/time-picker/index.d.ts +7 -0
  316. package/time-picker/index.es.js +1255 -1
  317. package/time-picker/index.umd.js +1 -1
  318. package/time-picker/style.css +1 -1
  319. package/toast/index.d.ts +7 -0
  320. package/toast/index.es.js +2060 -1
  321. package/toast/index.umd.js +1 -1
  322. package/toast/style.css +1 -1
  323. package/tooltip/index.d.ts +7 -0
  324. package/tooltip/index.es.js +171 -1
  325. package/tooltip/index.umd.js +1 -1
  326. package/transfer/index.d.ts +7 -0
  327. package/transfer/index.es.js +1725 -1
  328. package/transfer/index.umd.js +1 -1
  329. package/transfer/style.css +1 -1
  330. package/tree/index.d.ts +7 -0
  331. package/tree/index.es.js +907 -1
  332. package/tree/index.umd.js +1 -1
  333. package/tree/style.css +1 -1
  334. package/tree-select/index.d.ts +7 -0
  335. package/tree-select/index.es.js +528 -0
  336. package/tree-select/index.umd.js +1 -0
  337. package/tree-select/package.json +7 -0
  338. package/tree-select/style.css +1 -0
  339. package/upload/index.d.ts +7 -0
  340. package/upload/index.es.js +2834 -1
  341. package/upload/index.umd.js +1 -1
  342. package/upload/style.css +1 -1
  343. package/vue-devui.es.js +27743 -1
  344. package/vue-devui.umd.js +29 -1
@@ -1 +1,1172 @@
1
- var e=Object.defineProperty,t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,r=(t,n,a)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[n]=a;"undefined"!=typeof require&&require;import{defineComponent as o,computed as s,ref as l,watch as u,createVNode as i,withDirectives as d,mergeProps as c,resolveDirective as p,resolveComponent as g,createTextVNode as h,reactive as y,onMounted as m,onUnmounted as f}from"vue";const v=(e,t,n=2,a="0")=>(e+"").padStart(Math.min(t.length,n),a),w=(e,t)=>{const n=(e=>[e.getFullYear(),e.getMonth()+1,e.getDate(),e.getDay(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()])(t);let a=e;return a=a.replace(/y+/g,(e=>{const t=n[0]+"";return 2===e.length?t.substring(2):t})),a=a.replace(/M+/g,(e=>v(n[1],e))),a=a.replace(/d+/g,(e=>v(n[2],e))),a=a.replace(/h+/g,(e=>v(n[4],e))),a=a.replace(/m+/g,(e=>v(n[5],e))),a=a.replace(/s+/g,(e=>v(n[6],e))),a},x=(e,t)=>{if(!t)return!1;for(;e;){if(e===t)return!0;e=e.parentNode}return!1},M=(e,...t)=>{"function"==typeof e&&e(...t)},S=(e=new Date)=>{e instanceof Date||(e=new Date);const{year:t,month:n}=(e=>{const t=e.getFullYear(),n=e.getMonth()+1,a=e.getDate(),r=e.getDay(),o=e.getHours(),s=e.getMinutes(),l=e.getSeconds();return{year:t,y:t,month:n,M:n,date:a,d:a,day:r,hour:o,H:o,h:o,minute:s,m:s,second:l,s:l,ms:e.getMilliseconds()}})(e),a=((e,t)=>{const n=new Date(e,t-1,1),a=new Date(e,t,0),r=[];let o=n.getDay();for(;o>0;)o-=1,r.push({date:new Date(e,t-1,-o),current:-1});o=a.getDate()-n.getDate();for(let l=0;l<=o;l++){const e=new Date(n);e.setDate(l+1),r.push({date:e,current:0})}o=a.getDay();let s=a;for(let l=o;l<6;l++)s=new Date(e,t,l-o+1),r.push({date:s,current:1});if(r.length<42){o=s.getDate();for(let n=1;n<=7;n++)s=new Date(e,t,o+n),r.push({date:s,current:1})}return r})(t,n),r=[];for(;a.length>0;)r.push(a.splice(0,7));return r},b=["日","一","二","三","四","五","六"],D=(e,...t)=>{"function"==typeof e&&e(...t)},C=(e,t)=>(new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime())/864e5,F=(e,t,n,a)=>{return!e||!t||("year"===n?t.getFullYear()-e.getFullYear()>a:(o=e,12*(r=t).getFullYear()+r.getMonth()-(12*o.getFullYear()+o.getMonth())>a));var r,o},I=e=>{if(!e||"string"!=typeof e)return null;const[t="",n=""]=e.split(/([ ]|T)+/);if(!t)return null;const[a,r,o]=t.split(/[^\d]+/),s=Y(a),l=Y(r),u=Y(o)||1;if(!s||!l)return null;const i=$(n);return new Date(s,l-1,u,...i)},Y=(e,t)=>{if(!e||"string"!=typeof e)return t;const n=parseInt(e);return isNaN(n)?t:n},$=e=>{const[t,n,a,r]=e.split(/[\:\.]+/);return[Y(t,0),Y(n,0),Y(a,0),Y(r,0)]},P=(e,t,n="d")=>{const a=k(e,n),r=k(t,n);return a<r?-1:a>r?1:0},k=(e,t)=>{switch(t){case"y":return e.getFullYear();case"m":return 12*e.getFullYear()+e.getMonth()}return e.getTime()/864e5>>0},T=(e,t,n)=>!(t instanceof Date&&P(t,e,"d")>0)&&!(n instanceof Date&&P(e,n,"d")>0);var N=o({name:"DInput",directives:{focus:{mounted:function(e,t){t.value&&e.focus()}}},props:{placeholder:{type:String,default:void 0},disabled:{type:Boolean,default:!1},autoFocus:{type:Boolean,default:!1},maxLength:{type:Number,default:Number.MAX_SAFE_INTEGER},cssClass:{type:String,default:""},error:{type:Boolean,default:!1},size:{type:String,default:""},showPassword:{type:Boolean,default:!1},value:{type:String,default:""},"onUpdate:value":{type:Function,default:void 0},onChange:{type:Function,default:void 0},onKeydown:{type:Function,default:void 0},onFocus:{type:Function,default:void 0},onBlur:{type:Function,default:void 0}},emits:["update:value","focus","blur","change","keydown"],setup(e,t){const n=s((()=>`devui-input-${e.size}`)),a=l(!1),r=l("text"),o=s((()=>({error:e.error,[e.cssClass]:!0,[n.value]:""!==e.size}))),i=s((()=>"password"===r.value));u((()=>e.showPassword),(e=>{r.value=e?"password":"text"}),{immediate:!0}),u((()=>e.value),(e=>{e&&e.length>0&&i.value?a.value=!0:a.value=!1}));return{inputCls:o,inputType:r,showPreviewIcon:i,showPwdIcon:a,onInput:e=>{t.emit("update:value",e.target.value)},onFocus:()=>{t.emit("focus")},onBlur:()=>{t.emit("blur")},onChange:e=>{t.emit("change",e.target.value)},onKeydown:e=>{t.emit("keydown",e)},onChangeInputType:()=>{r.value="password"===r.value?"text":"password"}}},render(){const{value:e,showPreviewIcon:t,showPwdIcon:n,inputCls:a,inputType:r,maxLength:o,autoFocus:s,placeholder:l,disabled:u,onInput:h,onFocus:y,onBlur:m,onChange:f,onKeydown:v,onChangeInputType:w}=this;return i("div",{class:"devui-input__wrap"},[d(i("input",c({dinput:!0},{value:e,disabled:u,type:r,maxlength:o,placeholder:l,class:a,onInput:h,onFocus:y,onBlur:m,onChange:f,onKeydown:v}),null),[[p("focus"),s]]),n&&i("div",{class:"devui-input__preview",onClick:w},[i(g("d-icon"),t?{name:"preview",size:"12px",key:1}:{name:"preview-forbidden",size:"12px",key:2},null)])])}});N.install=function(e){e.component(N.name,N)};var B=o({name:"DIcon",props:{name:{type:String,required:!0},size:{type:String,default:"inherit"},color:{type:String,default:"inherit"},classPrefix:{type:String,default:"icon"}},setup:e=>((e,o)=>{for(var s in o||(o={}))n.call(o,s)&&r(e,s,o[s]);if(t)for(var s of t(o))a.call(o,s)&&r(e,s,o[s]);return e})({},e),render(){const{name:e,size:t,color:n,classPrefix:a}=this;return i("i",{class:`${a} ${a}-${e}`,style:{fontSize:t,color:n}},null)}});B.install=function(e){e.component(B.name,B)};const E=(e,t,n,a)=>{switch(t){case 0:const t=new Date(a);t.setFullYear(t.getFullYear()-1),0===n?e.current=t:e.next=t;break;case 1:const r=new Date(a);r.setMonth(r.getMonth()-1),0===n?e.current=r:e.next=r;break;case 2:const o=new Date(a);o.setMonth(o.getMonth()+1),0===n?e.current=o:e.next=o;break;case 3:const s=new Date(a);s.setFullYear(s.getFullYear()+1),0===n?e.current=s:e.next=s}},z=(e,t)=>{const{format:n="y/MM/dd",range:a,rangeSpliter:r="-"}=t||{};if(a){if(!e.start)return"";if(!e.end)return w(n,e.start);if(e.end<e.start){const t=e.end;e.end=e.start,e.start=t}return((e,t,n,a="-")=>{const r=[t,n];return t.getTime()>n.getTime()&&r.reverse(),`${w(e,r[0])} ${a} ${w(e,r[1])}`})(n,e.start,e.end,r)}return e.start?w(n,e.start):""},L=e=>{if(!e)return"";const t=e.format||"y/MM/dd",n=e.rangeSpliter||"-";return e.range?`${t} ${n} ${t}`:t},O=e=>e.toDateString(),H=(e,t,n="cell")=>{if(!T(t.date,e.dateMin,e.dateMax))return`${n} disabled`;if(0!==t.current)return`${n} not-current`;const a=O(t.date);if("range"===e.type){if(e.dateStart){if(O(e.dateStart)===a)return`${n} selected`;if(e.dateEnd&&O(e.dateEnd)===a)return`${n} selected`;const r=e.dateEnd||e.dateHover;if(r){const a=r>e.dateStart?[e.dateStart,r]:[r,e.dateStart];if(t.date>a[0]&&t.date<a[1])return`${n} innerday`}}return n}return e.dateStart&&O(e.dateStart)===a?`${n} selected`:n},A=e=>{const{color:t="#585d6b",rotate:n=0}=e;return i("svg",{style:{transform:`rotate(${n}deg)`},width:"10px",height:"10px",viewBox:"0 0 10 10",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},[i("g",{fill:t,transform:"translate(-1.000000, -1.000000)"},[i("path",{d:"M11,1.83333333 L11,10.1666667 L7,7.38833333 L7,10.1666667 L1,6 L7,1.83333333 L7,4.61033333 L11,1.83333333 Z"},null)])])},_=e=>{const{color:t="#585d6b",rotate:n=0}=e;return i("svg",{style:{transform:`rotate(${n}deg)`},width:"6px",height:"10px",viewBox:"0 0 6 10",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},[i("g",{fill:t,transform:"translate(-3.000000, -1.000000)"},[i("polygon",{points:"6 3 10.1666667 9 1.83333333 9"},null)])])};const R=e=>{const{button:t,disabled:n=!1,rotate:a=0,date:r,pos:o,cb:s}=e;return i("a",{class:""+(n?"disabled":""),onClick:n?void 0:()=>D(e.cb,r,o)},[i(t,{color:n?"#cfd0d3":"#585d6b",rotate:a},null)])},j=e=>{const{date:t}=e;return i("a",{class:"title"},[`${t.getFullYear()}年${(t.getMonth()+1+"").padStart(2,"0")}月`])},K=e=>{const{type:t,current:n,compare:a,pos:r,dateMax:o,dateMin:s,onPreviousYear:l,onPreviousMonth:u,onNextMonth:d,onNextYear:c}=e,p=[!1,!1,!1,!1];return"range"===t?1===r?(p[0]=!F(a,n,"year",1),p[1]=!F(a,n,"month",1),p[2]=!F(n,o,"month",0),p[3]=!F(n,o,"year",0)):(p[0]=!F(s,n,"year",0),p[1]=!F(s,n,"month",0),p[2]=!F(n,a,"month",1),p[3]=!F(n,a,"year",1)):(p[0]=!F(s,n,"year",0),p[1]=!F(s,n,"month",0),p[2]=!F(n,o,"month",0),p[3]=!F(n,o,"year",0)),i("div",{class:"devui-calendar-toolbar"},[i(R,{disabled:p[0],date:n,pos:r,button:A,cb:l},null),i(R,{disabled:p[1],date:n,pos:r,button:_,rotate:-90,cb:u},null),i(j,{date:n},null),i(R,{disabled:p[2],date:n,pos:r,button:_,rotate:90,cb:d},null),i(R,{disabled:p[3],date:n,pos:r,button:A,rotate:180,cb:c},null)])},q=e=>{const{onSelected:t=(()=>0),disabled:n=!1}=e;return i("div",{class:"today-container "+(n?"disabled":"")},[i("button",{class:"today-button",disabled:n,onClick:n?void 0:()=>t(new Date)},[h("今天")])])};const X=e=>{const t=new Date;return i("div",{class:"devui-calendar-panel"},[i(K,{current:e.current,compare:e.compare,pos:e.pos,type:e.type,showTime:e.showTime,onPreviousYear:e.onPreviousYear,onPreviousMonth:e.onPreviousMonth,onNextMonth:e.onNextMonth,onNextYear:e.onNextYear,dateMax:e.dateMax,dateMin:e.dateMin},null),i("ol",{class:"head row"},[b.map((e=>i("li",{class:"cell"},[e])))]),i("ul",{class:"body"},[S(e.current).map((t=>i("li",{class:"row"},[t.map((t=>i("span",{class:H(e,t),onClick:()=>((e,t)=>{T(t.date,e.dateMin,e.dateMax)&&("range"===e.type?e.dateStart?e.dateEnd?D(e.onReset,t.date):0!==C(e.dateStart,t.date)&&(D(e.onSelectEnd,t.date),"function"==typeof e.onChange&&e.onChange(e.type,e)):D(e.onSelectStart,t.date):(D(e.onSelected,t.date),"function"==typeof e.onChange&&e.onChange(e.type,e)))})(e,t),onMouseenter:()=>((e,t)=>{if(0!==t.current)return;const{dateMin:n,dateMax:a}=e;if(!(n&&C(t.date,n)<0||a&&C(a,t.date)<0||"range"!==e.type)){const n=O(t.date);if(!e.dateStart||O(e.dateStart)===n||e.dateEnd)return;D(e.onSelecting,t.date)}})(e,t)},[t.date.getDate()])))])))]),"range"!==e.type?i(q,{disabled:!T(t,e.dateMin,e.dateMax),onSelected:t=>{"function"==typeof e.onToday&&e.onToday(t,0)}},null):null])};const G=o({props:{size:{type:Number,default:26},items:{type:Array},selectedIndex:{type:Number},className:{type:String},itemClassNormal:{type:String},itemClassSelected:{type:String},onChange:{type:Function}},setup(e){const{items:t=[0,1,2,3,4,5,6,7,8,9],selectedIndex:n=0,size:a=26,className:r="",itemClassNormal:o="",itemClassSelected:s="selected",onChange:u}=e||{};let d=0,c=0;const p=l(),g=l();let h=null,f=null;const v=y({selectedIndex:n,barOpacity:0,x:0,y:0,transition:"none"}),w=e=>{e.stopPropagation(),e.preventDefault(),h=[e.clientX,e.clientY],v.transition="none"},x=e=>{e.stopPropagation(),e.preventDefault(),h&&f&&(v.x=f[0]+e.clientX-h[0],v.y=Math.min(d,Math.max(c,f[1]+e.clientY-h[1])),v.selectedIndex=(d-v.y+a/2)/a>>0)},M=e=>{if(e.stopPropagation(),e.preventDefault(),h=null,v.y=d-v.selectedIndex*a,v.transition="transform 0.1s",f[0]=v.x,f[1]=v.y,"function"==typeof u){const e=v.selectedIndex,n=t[e];u(n,e)}};return m((()=>{const{height:e}=p.value.getBoundingClientRect(),{height:t}=g.value.getBoundingClientRect();d=(e-a)/2,c=(e+a)/2-t,f=[0,d-v.selectedIndex*a],v.x=f[0],v.y=f[1],v.barOpacity=1,v.transition="transform 0.1s"})),()=>i("div",{ref:p,class:`devui-vertical-slider ${r}`},[i("div",{ref:g,class:"movable-bar",style:{opacity:v.barOpacity,transform:`translateY(${v.y}px)`,transition:v.transition}},[t.map(((e,t)=>{const n=t===v.selectedIndex?s:o;return i("span",{class:`slider-item ${n}`,style:{height:`${a}px`,lineHeight:`${a}px`}},[e])}))]),i("div",{class:"slider-mask",onMousedown:w,onMousemove:x,onMouseup:M,onMouseout:M},null)])}});const U=o({props:{time:{type:Date}},setup(e){const{time:t=new Date}=e||{},n=y({hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds()}),a=Array(24).fill(0).map(((e,t)=>`${t}`.padStart(2,"0"))),r=Array(60).fill(0).map(((e,t)=>`${t}`.padStart(2,"0")));return()=>i("div",{class:"devui-calendar-timepicker"},[i("div",{class:"head"},[i("div",{class:"chars"},[i("span",null,[n.hour.toString().padStart(2,"0"),h(":"),n.minute.toString().padStart(2,"0"),h(":"),n.second.toString().padStart(2,"0")])])]),i("div",{class:"select"},[i(G,{items:a,selectedIndex:n.hour,onChange:(e,t)=>n.hour=t},null),i(G,{items:r,selectedIndex:n.minute,onChange:(e,t)=>n.minute=t},null),i(G,{items:r,selectedIndex:n.second,onChange:(e,t)=>n.second=t},null)])])}});const Z=e=>{const{showTime:t=!1}=e;let{current:n}=e;if(n instanceof Date||(n=new Date),"range"===e.type){let{next:a}=e;return a instanceof Date||(a=new Date(n.getFullYear(),n.getMonth()+1,1)),i("div",{class:"devui-calendar-container"},[i(X,c(e,{pos:0,current:n,compare:a}),null),t?i(U,{time:n},null):null,i(X,c(e,{pos:1,current:a,compare:n}),null),t?i(U,{time:a},null):null])}return i("div",{class:"devui-calendar-container"},[i(X,c(e,{pos:0,current:n}),null),t?i(U,{time:n},null):null])};var J=o({name:"DDatepicker",props:{selectedDateChange:{type:Function},autoClose:{type:Boolean,default:!1},range:{type:Boolean,default:!1},showTime:{type:Boolean,default:!1},format:{type:String,default:"y/MM/dd"},rangeSpliter:{type:String,default:"-"},attachInputDom:{type:String},dateMin:{type:String},dateMax:{type:String}},setup(e,t){const n=l(null),a=l(null),r=I(e.dateMin)||new Date,o=new Date(r.getFullYear(),r.getMonth()+1,1),s=y({show:!1,value:"",placeholder:L(e),current:r,next:o});s.value=z(s,e),s.placeholder=L(e);const u=e=>{e.stopPropagation(),x(e.target,n.value)||x(e.target,a.value)||(s.show=!1)};return m((()=>{document.addEventListener("click",u)})),f((()=>{document.removeEventListener("click",u)})),()=>i("div",{class:"devui-datepicker-container"},[i("div",{class:"input-container",ref:a},[i(N,{ref:a,class:"datepicker-input",value:s.value,placeholder:s.placeholder,onFocus:()=>s.show=!0},null),i(B,{size:"small",name:"calendar",class:"datepicker-input-icon"},null)]),i("div",{class:"devui-datepicker-panel",ref:n},[s.show?i(Z,{type:e.range?"range":"select",showTime:e.showTime,current:s.current,next:s.next,dateMin:I(e.dateMin),dateMax:I(e.dateMax),dateStart:s.start,dateEnd:s.end,dateHover:s.hover,onReset:e=>{s.end=s.hover=void 0,s.start=e},onChange:(t,n)=>{s.value=z(s,e),s.placeholder=L(e),M(e.selectedDateChange,s.value),e.autoClose&&(s.show=!1)},onToday:t=>{s.current=t,s.start=t,s.value=z(s,e),s.placeholder=L(e),M(e.selectedDateChange,s.value),e.autoClose&&(s.show=!1)},onSelected:e=>{s.start=e,0!==P(s.current,e)&&(s.current=e)},onSelectStart:e=>s.start=e,onSelectEnd:e=>{s.end=e,(e=>{const[t,n]=[e.start,e.end].sort(((e,t)=>e.getTime()-t.getTime()));e.start=t,e.end=n,0!==P(t,n,"m")?(e.current=t,e.next=n):(P(t,e.current)<0&&(e.current=t),P(e.next,n)<0&&(e.next=n))})(s)},onSelecting:e=>s.hover=e,onPreviousYear:(e,t)=>E(s,0,t,e),onPreviousMonth:(e,t)=>E(s,1,t,e),onNextMonth:(e,t)=>E(s,2,t,e),onNextYear:(e,t)=>E(s,3,t,e)},null):null])])}});const Q=o({name:"DStickSlider",props:{},setup(e){const t=y({showButtons:!1,selectedIndex:0}),n=e=>{e.stopPropagation(),t.showButtons=!0},a=e=>{e.stopPropagation(),t.showButtons=!1};return()=>i("div",{class:"devui-stick-slider",onMousedown:n,onMouseup:a,onMouseleave:a},[i("div",{class:"sub-buttons",style:{display:t.showButtons?"":"none"}},[Array(16).fill(null).map(((e,n)=>i("div",{class:"button "+(n===t.selectedIndex?"selected":""),onMouseenter:()=>t.selectedIndex=n},[n])))]),i("div",{class:"main-button"},null)])}});J.install=function(e){e.component(J.name,J),e.component(Q.name,Q)};var V={title:"DatePicker 日期选择器",category:"数据录入",install(e){e.use(J)}};export{J as DatePicker,Q as StickSlider,V as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { defineComponent, inject, computed, ref, watch, createVNode, withDirectives, mergeProps, resolveDirective, resolveComponent, createTextVNode, reactive, onMounted, onUnmounted } from "vue";
18
+ const getDateTime = (d) => {
19
+ const year = d.getFullYear();
20
+ const month = d.getMonth() + 1;
21
+ const date = d.getDate();
22
+ const day = d.getDay();
23
+ const hour = d.getHours();
24
+ const minute = d.getMinutes();
25
+ const second = d.getSeconds();
26
+ const ms = d.getMilliseconds();
27
+ return [year, month, date, day, hour, minute, second, ms];
28
+ };
29
+ const fixStart = (n, m, max = 2, ch = "0") => {
30
+ return (n + "").padStart(Math.min(m.length, max), ch);
31
+ };
32
+ const formatDate = (fmt, d) => {
33
+ const usage = getDateTime(d);
34
+ let res = fmt;
35
+ res = res.replace(/y+/g, (m) => {
36
+ const year = usage[0] + "";
37
+ if (m.length === 2) {
38
+ return year.substring(2);
39
+ }
40
+ return year;
41
+ });
42
+ res = res.replace(/M+/g, (m) => fixStart(usage[1], m));
43
+ res = res.replace(/d+/g, (m) => fixStart(usage[2], m));
44
+ res = res.replace(/h+/g, (m) => fixStart(usage[4], m));
45
+ res = res.replace(/m+/g, (m) => fixStart(usage[5], m));
46
+ res = res.replace(/s+/g, (m) => fixStart(usage[6], m));
47
+ return res;
48
+ };
49
+ const formatRange$1 = (fmt, a, b, conn = "-") => {
50
+ const ab = [a, b];
51
+ if (a.getTime() > b.getTime()) {
52
+ ab.reverse();
53
+ }
54
+ return `${formatDate(fmt, ab[0])} ${conn} ${formatDate(fmt, ab[1])}`;
55
+ };
56
+ const isIn = (a, b) => {
57
+ if (!b) {
58
+ return false;
59
+ }
60
+ while (a) {
61
+ if (a === b) {
62
+ return true;
63
+ }
64
+ a = a.parentNode;
65
+ }
66
+ return false;
67
+ };
68
+ const invokeFunction = (fn, ...args) => {
69
+ if (typeof fn === "function") {
70
+ fn(...args);
71
+ }
72
+ };
73
+ const getHumanDate = (d) => {
74
+ const year = d.getFullYear();
75
+ const month = d.getMonth() + 1;
76
+ const date = d.getDate();
77
+ const day = d.getDay();
78
+ const hour = d.getHours();
79
+ const minute = d.getMinutes();
80
+ const second = d.getSeconds();
81
+ const ms = d.getMilliseconds();
82
+ return {
83
+ year,
84
+ y: year,
85
+ month,
86
+ M: month,
87
+ date,
88
+ d: date,
89
+ day,
90
+ hour,
91
+ H: hour,
92
+ h: hour,
93
+ minute,
94
+ m: minute,
95
+ second,
96
+ s: second,
97
+ ms
98
+ };
99
+ };
100
+ const getMonthDays = (year, month) => {
101
+ const first = new Date(year, month - 1, 1);
102
+ const last = new Date(year, month, 0);
103
+ const dates = [];
104
+ let day = first.getDay();
105
+ while (day > 0) {
106
+ day -= 1;
107
+ dates.push({ date: new Date(year, month - 1, -day), current: -1 });
108
+ }
109
+ day = last.getDate() - first.getDate();
110
+ for (let i = 0; i <= day; i++) {
111
+ const date = new Date(first);
112
+ date.setDate(i + 1);
113
+ dates.push({ date, current: 0 });
114
+ }
115
+ day = last.getDay();
116
+ let tail = last;
117
+ for (let i = day; i < 6; i++) {
118
+ tail = new Date(year, month, i - day + 1);
119
+ dates.push({ date: tail, current: 1 });
120
+ }
121
+ if (dates.length < 42) {
122
+ day = tail.getDate();
123
+ for (let i = 1; i <= 7; i++) {
124
+ tail = new Date(year, month, day + i);
125
+ dates.push({ date: tail, current: 1 });
126
+ }
127
+ }
128
+ return dates;
129
+ };
130
+ const getMonthWeeklyDays = (date = new Date()) => {
131
+ if (!(date instanceof Date)) {
132
+ date = new Date();
133
+ }
134
+ const { year, month } = getHumanDate(date);
135
+ const days = getMonthDays(year, month);
136
+ const dayRows = [];
137
+ while (days.length > 0) {
138
+ dayRows.push(days.splice(0, 7));
139
+ }
140
+ return dayRows;
141
+ };
142
+ const WEEK_DAYS = ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"];
143
+ const invokeCallback = (cb, ...args) => {
144
+ typeof cb === "function" && cb(...args);
145
+ };
146
+ const subDateMonth = (a, b) => {
147
+ const am = a.getFullYear() * 12 + a.getMonth();
148
+ const bm = b.getFullYear() * 12 + b.getMonth();
149
+ return am - bm;
150
+ };
151
+ const ONE_DAY = 1e3 * 60 * 60 * 24;
152
+ const subDateDay = (a, b) => {
153
+ const ad = new Date(a.getFullYear(), a.getMonth(), a.getDate()).getTime();
154
+ const bd = new Date(b.getFullYear(), b.getMonth(), b.getDate()).getTime();
155
+ return (ad - bd) / ONE_DAY;
156
+ };
157
+ const compareDate = (small, big, mode, min) => {
158
+ if (!small || !big) {
159
+ return true;
160
+ }
161
+ if (mode === "year") {
162
+ return big.getFullYear() - small.getFullYear() > min;
163
+ } else {
164
+ return subDateMonth(big, small) > min;
165
+ }
166
+ };
167
+ const parseDate = (str) => {
168
+ if (!str || typeof str !== "string") {
169
+ return null;
170
+ }
171
+ const [dateStr = "", timeStr = ""] = str.split(/([ ]|T)+/);
172
+ if (!dateStr) {
173
+ return null;
174
+ }
175
+ const [y, m, d] = dateStr.split(/[^\d]+/);
176
+ const year = _parseInt(y), month = _parseInt(m), date = _parseInt(d) || 1;
177
+ if (!year || !month) {
178
+ return null;
179
+ }
180
+ const time = parseTime(timeStr);
181
+ return new Date(year, month - 1, date, ...time);
182
+ };
183
+ const _parseInt = (str, dftVal) => {
184
+ if (!str || typeof str !== "string") {
185
+ return dftVal;
186
+ }
187
+ const n = parseInt(str);
188
+ if (isNaN(n)) {
189
+ return dftVal;
190
+ }
191
+ return n;
192
+ };
193
+ const parseTime = (str) => {
194
+ const [h, m, s, ms] = str.split(/[\:\.]+/);
195
+ return [_parseInt(h, 0), _parseInt(m, 0), _parseInt(s, 0), _parseInt(ms, 0)];
196
+ };
197
+ const compareDateSort = (d1, d2, type = "d") => {
198
+ const t1 = dateCounter(d1, type), t2 = dateCounter(d2, type);
199
+ return t1 < t2 ? -1 : t1 > t2 ? 1 : 0;
200
+ };
201
+ const dateCounter = (date, type) => {
202
+ switch (type) {
203
+ case "y":
204
+ return date.getFullYear();
205
+ case "m":
206
+ return date.getFullYear() * 12 + date.getMonth();
207
+ }
208
+ return date.getTime() / ONE_DAY >> 0;
209
+ };
210
+ const betweenDate = (date, left, right) => {
211
+ if (left instanceof Date && compareDateSort(left, date, "d") > 0) {
212
+ return false;
213
+ }
214
+ if (right instanceof Date && compareDateSort(date, right, "d") > 0) {
215
+ return false;
216
+ }
217
+ return true;
218
+ };
219
+ const inputProps = {
220
+ placeholder: {
221
+ type: String,
222
+ default: void 0
223
+ },
224
+ disabled: {
225
+ type: Boolean,
226
+ default: false
227
+ },
228
+ autoFocus: {
229
+ type: Boolean,
230
+ default: false
231
+ },
232
+ maxLength: {
233
+ type: Number,
234
+ default: Number.MAX_SAFE_INTEGER
235
+ },
236
+ cssClass: {
237
+ type: String,
238
+ default: ""
239
+ },
240
+ error: {
241
+ type: Boolean,
242
+ default: false
243
+ },
244
+ size: {
245
+ type: String,
246
+ default: ""
247
+ },
248
+ showPassword: {
249
+ type: Boolean,
250
+ default: false
251
+ },
252
+ modelValue: {
253
+ type: String,
254
+ default: ""
255
+ },
256
+ "update:modelValue": {
257
+ type: Function,
258
+ default: void 0
259
+ },
260
+ onChange: {
261
+ type: Function,
262
+ default: void 0
263
+ },
264
+ onKeydown: {
265
+ type: Function,
266
+ default: void 0
267
+ },
268
+ onFocus: {
269
+ type: Function,
270
+ default: void 0
271
+ },
272
+ onBlur: {
273
+ type: Function,
274
+ default: void 0
275
+ }
276
+ };
277
+ var input = "";
278
+ const formItemInjectionKey = Symbol("dFormItem");
279
+ const dFormItemEvents = {
280
+ blur: "d.form.blur",
281
+ change: "d.form.change",
282
+ input: "d.form.input"
283
+ };
284
+ var Input = defineComponent({
285
+ name: "DInput",
286
+ directives: {
287
+ focus: {
288
+ mounted: function(el, binding) {
289
+ if (binding.value) {
290
+ el.focus();
291
+ }
292
+ }
293
+ }
294
+ },
295
+ props: inputProps,
296
+ emits: ["update:modelValue", "focus", "blur", "change", "keydown"],
297
+ setup(props, ctx) {
298
+ const formItem = inject(formItemInjectionKey, {});
299
+ const hasFormItem = Object.keys(formItem).length > 0;
300
+ const sizeCls = computed(() => `devui-input-${props.size}`);
301
+ const showPwdIcon = ref(false);
302
+ const inputType = ref("text");
303
+ const inputCls = computed(() => {
304
+ return {
305
+ error: props.error,
306
+ [props.cssClass]: true,
307
+ [sizeCls.value]: props.size !== ""
308
+ };
309
+ });
310
+ const showPreviewIcon = computed(() => inputType.value === "password");
311
+ watch(() => props.showPassword, (flg) => {
312
+ inputType.value = flg ? "password" : "text";
313
+ }, {
314
+ immediate: true
315
+ });
316
+ watch(() => props.modelValue, (value) => {
317
+ value && value.length > 0 && showPreviewIcon.value ? showPwdIcon.value = true : showPwdIcon.value = false;
318
+ });
319
+ const onInput = ($event) => {
320
+ ctx.emit("update:modelValue", $event.target.value);
321
+ hasFormItem && formItem.formItemMitt.emit(dFormItemEvents.input);
322
+ }, onFocus = () => {
323
+ ctx.emit("focus");
324
+ }, onBlur = () => {
325
+ ctx.emit("blur");
326
+ hasFormItem && formItem.formItemMitt.emit(dFormItemEvents.blur);
327
+ }, onChange = ($event) => {
328
+ ctx.emit("change", $event.target.value);
329
+ hasFormItem && formItem.formItemMitt.emit(dFormItemEvents.change);
330
+ }, onKeydown = ($event) => {
331
+ ctx.emit("keydown", $event);
332
+ }, onChangeInputType = () => {
333
+ inputType.value = inputType.value === "password" ? "text" : "password";
334
+ };
335
+ return {
336
+ inputCls,
337
+ inputType,
338
+ showPreviewIcon,
339
+ showPwdIcon,
340
+ onInput,
341
+ onFocus,
342
+ onBlur,
343
+ onChange,
344
+ onKeydown,
345
+ onChangeInputType
346
+ };
347
+ },
348
+ render() {
349
+ const {
350
+ modelValue,
351
+ showPreviewIcon,
352
+ showPwdIcon,
353
+ inputCls,
354
+ inputType,
355
+ maxLength,
356
+ autoFocus,
357
+ placeholder,
358
+ disabled,
359
+ onInput,
360
+ onFocus,
361
+ onBlur,
362
+ onChange,
363
+ onKeydown,
364
+ onChangeInputType
365
+ } = this;
366
+ return createVNode("div", {
367
+ "class": "devui-input__wrap"
368
+ }, [withDirectives(createVNode("input", mergeProps({
369
+ dinput: true
370
+ }, {
371
+ "value": modelValue,
372
+ "disabled": disabled,
373
+ "type": inputType,
374
+ "maxlength": maxLength,
375
+ "placeholder": placeholder,
376
+ "class": inputCls,
377
+ "onInput": onInput,
378
+ "onFocus": onFocus,
379
+ "onBlur": onBlur,
380
+ "onChange": onChange,
381
+ "onKeydown": onKeydown
382
+ }), null), [[resolveDirective("focus"), autoFocus]]), showPwdIcon && createVNode("div", {
383
+ "class": "devui-input__preview",
384
+ "onClick": onChangeInputType
385
+ }, [showPreviewIcon ? createVNode(resolveComponent("d-icon"), {
386
+ "name": "preview",
387
+ "size": "12px",
388
+ "key": 1
389
+ }, null) : createVNode(resolveComponent("d-icon"), {
390
+ "name": "preview-forbidden",
391
+ "size": "12px",
392
+ "key": 2
393
+ }, null)])]);
394
+ }
395
+ });
396
+ Input.install = function(app) {
397
+ app.component(Input.name, Input);
398
+ };
399
+ var Icon = defineComponent({
400
+ name: "DIcon",
401
+ props: {
402
+ name: {
403
+ type: String,
404
+ required: true
405
+ },
406
+ size: {
407
+ type: String,
408
+ default: "inherit"
409
+ },
410
+ color: {
411
+ type: String,
412
+ default: "inherit"
413
+ },
414
+ classPrefix: {
415
+ type: String,
416
+ default: "icon"
417
+ }
418
+ },
419
+ setup(props) {
420
+ return __spreadValues({}, props);
421
+ },
422
+ render() {
423
+ const {
424
+ name,
425
+ size,
426
+ color,
427
+ classPrefix
428
+ } = this;
429
+ return /^((https?):)?\/\//.test(name) ? createVNode("img", {
430
+ "src": name,
431
+ "alt": name.split("/")[name.split("/").length - 1],
432
+ "style": {
433
+ width: size,
434
+ verticalAlign: "text-bottom"
435
+ }
436
+ }, null) : createVNode("i", {
437
+ "class": `${classPrefix} ${classPrefix}-${name}`,
438
+ "style": {
439
+ fontSize: size,
440
+ color
441
+ }
442
+ }, null);
443
+ }
444
+ });
445
+ Icon.install = function(app) {
446
+ app.component(Icon.name, Icon);
447
+ };
448
+ const handleCalendarSwitchState = (state, index2, pos, date) => {
449
+ switch (index2) {
450
+ case 0:
451
+ const preYear = new Date(date);
452
+ preYear.setFullYear(preYear.getFullYear() - 1);
453
+ pos === 0 ? state.current = preYear : state.next = preYear;
454
+ break;
455
+ case 1:
456
+ const preMonth = new Date(date);
457
+ preMonth.setMonth(preMonth.getMonth() - 1);
458
+ pos === 0 ? state.current = preMonth : state.next = preMonth;
459
+ break;
460
+ case 2:
461
+ const nextMonth = new Date(date);
462
+ nextMonth.setMonth(nextMonth.getMonth() + 1);
463
+ pos === 0 ? state.current = nextMonth : state.next = nextMonth;
464
+ break;
465
+ case 3:
466
+ const nextYear = new Date(date);
467
+ nextYear.setFullYear(nextYear.getFullYear() + 1);
468
+ pos === 0 ? state.current = nextYear : state.next = nextYear;
469
+ break;
470
+ }
471
+ };
472
+ const formatValue = (state, props) => {
473
+ const { format = "y/MM/dd", range, rangeSpliter = "-" } = props || {};
474
+ if (range) {
475
+ if (!state.start) {
476
+ return "";
477
+ } else if (!state.end) {
478
+ return formatDate(format, state.start);
479
+ }
480
+ if (state.end < state.start) {
481
+ const end = state.end;
482
+ state.end = state.start;
483
+ state.start = end;
484
+ }
485
+ return formatRange$1(format, state.start, state.end, rangeSpliter);
486
+ } else {
487
+ if (!state.start) {
488
+ return "";
489
+ }
490
+ return formatDate(format, state.start);
491
+ }
492
+ };
493
+ const formatPlaceholder = (props) => {
494
+ if (!props)
495
+ return "";
496
+ const format = props.format || `y/MM/dd`;
497
+ const sp = props.rangeSpliter || "-";
498
+ return props.range ? `${format} ${sp} ${format}` : format;
499
+ };
500
+ const getDateKey = (date) => {
501
+ return date.toDateString();
502
+ };
503
+ const cellClassName = (props, day, base = "cell") => {
504
+ if (!betweenDate(day.date, props.dateMin, props.dateMax)) {
505
+ return `${base} disabled`;
506
+ } else if (day.current !== 0) {
507
+ return `${base} not-current`;
508
+ }
509
+ const key = getDateKey(day.date);
510
+ if (props.type === "range") {
511
+ if (props.dateStart) {
512
+ if (getDateKey(props.dateStart) === key) {
513
+ return `${base} selected`;
514
+ }
515
+ if (props.dateEnd && getDateKey(props.dateEnd) === key) {
516
+ return `${base} selected`;
517
+ }
518
+ const innerEnd = props.dateEnd || props.dateHover;
519
+ if (innerEnd) {
520
+ const range = innerEnd > props.dateStart ? [props.dateStart, innerEnd] : [innerEnd, props.dateStart];
521
+ if (day.date > range[0] && day.date < range[1]) {
522
+ return `${base} innerday`;
523
+ }
524
+ }
525
+ }
526
+ return base;
527
+ } else {
528
+ return props.dateStart && getDateKey(props.dateStart) === key ? `${base} selected` : base;
529
+ }
530
+ };
531
+ const trigEvent = (props, day) => {
532
+ if (!betweenDate(day.date, props.dateMin, props.dateMax)) {
533
+ return;
534
+ }
535
+ if (props.type === "range") {
536
+ if (!props.dateStart) {
537
+ invokeCallback(props.onSelectStart, day.date);
538
+ } else if (!props.dateEnd) {
539
+ if (subDateDay(props.dateStart, day.date) !== 0) {
540
+ invokeCallback(props.onSelectEnd, day.date);
541
+ typeof props.onChange === "function" && props.onChange(props.type, props);
542
+ }
543
+ } else {
544
+ invokeCallback(props.onReset, day.date);
545
+ }
546
+ } else {
547
+ invokeCallback(props.onSelected, day.date);
548
+ typeof props.onChange === "function" && props.onChange(props.type, props);
549
+ }
550
+ };
551
+ const handleDateEnter = (props, day) => {
552
+ if (day.current !== 0) {
553
+ return;
554
+ }
555
+ const { dateMin, dateMax } = props;
556
+ if (dateMin && subDateDay(day.date, dateMin) < 0) {
557
+ return;
558
+ }
559
+ if (dateMax && subDateDay(dateMax, day.date) < 0) {
560
+ return;
561
+ }
562
+ if (props.type === "range") {
563
+ const key = getDateKey(day.date);
564
+ if (!props.dateStart || getDateKey(props.dateStart) === key || props.dateEnd) {
565
+ return;
566
+ }
567
+ invokeCallback(props.onSelecting, day.date);
568
+ }
569
+ };
570
+ const Year = (props) => {
571
+ const {
572
+ color = "#585d6b",
573
+ rotate = 0
574
+ } = props;
575
+ return createVNode("svg", {
576
+ "style": {
577
+ transform: `rotate(${rotate}deg)`
578
+ },
579
+ "width": "10px",
580
+ "height": "10px",
581
+ "viewBox": "0 0 10 10",
582
+ "version": "1.1",
583
+ "xmlns": "http://www.w3.org/2000/svg"
584
+ }, [createVNode("g", {
585
+ "fill": color,
586
+ "transform": "translate(-1.000000, -1.000000)"
587
+ }, [createVNode("path", {
588
+ "d": "M11,1.83333333 L11,10.1666667 L7,7.38833333 L7,10.1666667 L1,6 L7,1.83333333 L7,4.61033333 L11,1.83333333 Z"
589
+ }, null)])]);
590
+ };
591
+ const Month = (props) => {
592
+ const {
593
+ color = "#585d6b",
594
+ rotate = 0
595
+ } = props;
596
+ return createVNode("svg", {
597
+ "style": {
598
+ transform: `rotate(${rotate}deg)`
599
+ },
600
+ "width": "6px",
601
+ "height": "10px",
602
+ "viewBox": "0 0 6 10",
603
+ "version": "1.1",
604
+ "xmlns": "http://www.w3.org/2000/svg"
605
+ }, [createVNode("g", {
606
+ "fill": color,
607
+ "transform": "translate(-3.000000, -1.000000)"
608
+ }, [createVNode("polygon", {
609
+ "points": "6 3 10.1666667 9 1.83333333 9"
610
+ }, null)])]);
611
+ };
612
+ var index$6 = "";
613
+ const Item = (props) => {
614
+ const {
615
+ button: Btn,
616
+ disabled = false,
617
+ rotate = 0,
618
+ date,
619
+ pos
620
+ } = props;
621
+ const color = disabled ? "#cfd0d3" : "#585d6b";
622
+ const className = `${disabled ? "disabled" : ""}`;
623
+ const handleClick = disabled ? void 0 : () => invokeCallback(props.cb, date, pos);
624
+ return createVNode("a", {
625
+ "class": className,
626
+ "onClick": handleClick
627
+ }, [createVNode(Btn, {
628
+ "color": color,
629
+ "rotate": rotate
630
+ }, null)]);
631
+ };
632
+ const Title = (props) => {
633
+ const {
634
+ date
635
+ } = props;
636
+ return createVNode("a", {
637
+ "class": "title"
638
+ }, [`${date.getFullYear()}\u5E74${(date.getMonth() + 1 + "").padStart(2, "0")}\u6708`]);
639
+ };
640
+ const CalendarToolbar = (props) => {
641
+ const {
642
+ type,
643
+ current,
644
+ compare,
645
+ pos,
646
+ dateMax,
647
+ dateMin,
648
+ onPreviousYear,
649
+ onPreviousMonth,
650
+ onNextMonth,
651
+ onNextYear
652
+ } = props;
653
+ const dis = [false, false, false, false];
654
+ if (type === "range") {
655
+ if (pos === 1) {
656
+ dis[0] = !compareDate(compare, current, "year", 1);
657
+ dis[1] = !compareDate(compare, current, "month", 1);
658
+ dis[2] = !compareDate(current, dateMax, "month", 0);
659
+ dis[3] = !compareDate(current, dateMax, "year", 0);
660
+ } else {
661
+ dis[0] = !compareDate(dateMin, current, "year", 0);
662
+ dis[1] = !compareDate(dateMin, current, "month", 0);
663
+ dis[2] = !compareDate(current, compare, "month", 1);
664
+ dis[3] = !compareDate(current, compare, "year", 1);
665
+ }
666
+ } else {
667
+ dis[0] = !compareDate(dateMin, current, "year", 0);
668
+ dis[1] = !compareDate(dateMin, current, "month", 0);
669
+ dis[2] = !compareDate(current, dateMax, "month", 0);
670
+ dis[3] = !compareDate(current, dateMax, "year", 0);
671
+ }
672
+ return createVNode("div", {
673
+ "class": "devui-calendar-toolbar"
674
+ }, [createVNode(Item, {
675
+ "disabled": dis[0],
676
+ "date": current,
677
+ "pos": pos,
678
+ "button": Year,
679
+ "cb": onPreviousYear
680
+ }, null), createVNode(Item, {
681
+ "disabled": dis[1],
682
+ "date": current,
683
+ "pos": pos,
684
+ "button": Month,
685
+ "rotate": -90,
686
+ "cb": onPreviousMonth
687
+ }, null), createVNode(Title, {
688
+ "date": current
689
+ }, null), createVNode(Item, {
690
+ "disabled": dis[2],
691
+ "date": current,
692
+ "pos": pos,
693
+ "button": Month,
694
+ "rotate": 90,
695
+ "cb": onNextMonth
696
+ }, null), createVNode(Item, {
697
+ "disabled": dis[3],
698
+ "date": current,
699
+ "pos": pos,
700
+ "button": Year,
701
+ "rotate": 180,
702
+ "cb": onNextYear
703
+ }, null)]);
704
+ };
705
+ const TodayDefault = (props) => {
706
+ const {
707
+ onSelected = () => 0,
708
+ disabled = false
709
+ } = props;
710
+ return createVNode("div", {
711
+ "class": `today-container ${disabled ? "disabled" : ""}`
712
+ }, [createVNode("button", {
713
+ "class": "today-button",
714
+ "disabled": disabled,
715
+ "onClick": disabled ? void 0 : () => onSelected(new Date())
716
+ }, [createTextVNode("\u4ECA\u5929")])]);
717
+ };
718
+ var index$5 = "";
719
+ const CalendarDatePanel = (props) => {
720
+ const today = new Date();
721
+ return createVNode("div", {
722
+ "class": "devui-calendar-panel"
723
+ }, [createVNode(CalendarToolbar, {
724
+ "current": props.current,
725
+ "compare": props.compare,
726
+ "pos": props.pos,
727
+ "type": props.type,
728
+ "showTime": props.showTime,
729
+ "onPreviousYear": props.onPreviousYear,
730
+ "onPreviousMonth": props.onPreviousMonth,
731
+ "onNextMonth": props.onNextMonth,
732
+ "onNextYear": props.onNextYear,
733
+ "dateMax": props.dateMax,
734
+ "dateMin": props.dateMin
735
+ }, null), createVNode("ol", {
736
+ "class": "head row"
737
+ }, [WEEK_DAYS.map((day) => createVNode("li", {
738
+ "class": "cell"
739
+ }, [day]))]), createVNode("ul", {
740
+ "class": "body"
741
+ }, [getMonthWeeklyDays(props.current).map((row) => createVNode("li", {
742
+ "class": "row"
743
+ }, [row.map((day) => {
744
+ return createVNode("span", {
745
+ "class": cellClassName(props, day),
746
+ "onClick": () => trigEvent(props, day),
747
+ "onMouseenter": () => handleDateEnter(props, day)
748
+ }, [day.date.getDate()]);
749
+ })]))]), props.type !== "range" ? createVNode(TodayDefault, {
750
+ "disabled": !betweenDate(today, props.dateMin, props.dateMax),
751
+ "onSelected": (today2) => {
752
+ typeof props.onToday === "function" && props.onToday(today2, 0);
753
+ }
754
+ }, null) : null]);
755
+ };
756
+ var index$4 = "";
757
+ const VerticalSlider = defineComponent({
758
+ props: {
759
+ size: {
760
+ type: Number,
761
+ default: 26
762
+ },
763
+ items: {
764
+ type: Array
765
+ },
766
+ selectedIndex: {
767
+ type: Number
768
+ },
769
+ className: {
770
+ type: String
771
+ },
772
+ itemClassNormal: {
773
+ type: String
774
+ },
775
+ itemClassSelected: {
776
+ type: String
777
+ },
778
+ onChange: {
779
+ type: Function
780
+ }
781
+ },
782
+ setup(props) {
783
+ const {
784
+ items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
785
+ selectedIndex = 0,
786
+ size = 26,
787
+ className = "",
788
+ itemClassNormal = "",
789
+ itemClassSelected = "selected",
790
+ onChange
791
+ } = props || {};
792
+ let max_y = 0, min_y = 0;
793
+ const container = ref();
794
+ const movbar = ref();
795
+ let pos_start = null;
796
+ let pos_cache = null;
797
+ const state = reactive({
798
+ selectedIndex,
799
+ barOpacity: 0,
800
+ x: 0,
801
+ y: 0,
802
+ transition: "none"
803
+ });
804
+ const handleMouseDown = (e) => {
805
+ e.stopPropagation();
806
+ e.preventDefault();
807
+ pos_start = [e.clientX, e.clientY];
808
+ state.transition = "none";
809
+ };
810
+ const handleMouseMove = (e) => {
811
+ e.stopPropagation();
812
+ e.preventDefault();
813
+ if (!pos_start || !pos_cache) {
814
+ return;
815
+ }
816
+ state.x = pos_cache[0] + e.clientX - pos_start[0];
817
+ state.y = Math.min(max_y, Math.max(min_y, pos_cache[1] + e.clientY - pos_start[1]));
818
+ state.selectedIndex = (max_y - state.y + size / 2) / size >> 0;
819
+ };
820
+ const handleMouseUp = (e) => {
821
+ e.stopPropagation();
822
+ e.preventDefault();
823
+ pos_start = null;
824
+ state.y = max_y - state.selectedIndex * size;
825
+ state.transition = "transform 0.1s";
826
+ pos_cache[0] = state.x;
827
+ pos_cache[1] = state.y;
828
+ if (typeof onChange === "function") {
829
+ const idx = state.selectedIndex;
830
+ const val = items[idx];
831
+ onChange(val, idx);
832
+ }
833
+ };
834
+ onMounted(() => {
835
+ const {
836
+ height: ch
837
+ } = container.value.getBoundingClientRect();
838
+ const {
839
+ height: mh
840
+ } = movbar.value.getBoundingClientRect();
841
+ max_y = (ch - size) / 2;
842
+ min_y = (ch + size) / 2 - mh;
843
+ pos_cache = [0, max_y - state.selectedIndex * size];
844
+ state.x = pos_cache[0];
845
+ state.y = pos_cache[1];
846
+ state.barOpacity = 1;
847
+ state.transition = "transform 0.1s";
848
+ });
849
+ return () => {
850
+ return createVNode("div", {
851
+ "ref": container,
852
+ "class": `devui-vertical-slider ${className}`
853
+ }, [createVNode("div", {
854
+ "ref": movbar,
855
+ "class": "movable-bar",
856
+ "style": {
857
+ opacity: state.barOpacity,
858
+ transform: `translateY(${state.y}px)`,
859
+ transition: state.transition
860
+ }
861
+ }, [items.map((c, i) => {
862
+ const className2 = i === state.selectedIndex ? itemClassSelected : itemClassNormal;
863
+ return createVNode("span", {
864
+ "class": `slider-item ${className2}`,
865
+ "style": {
866
+ height: `${size}px`,
867
+ lineHeight: `${size}px`
868
+ }
869
+ }, [c]);
870
+ })]), createVNode("div", {
871
+ "class": "slider-mask",
872
+ "onMousedown": handleMouseDown,
873
+ "onMousemove": handleMouseMove,
874
+ "onMouseup": handleMouseUp,
875
+ "onMouseout": handleMouseUp
876
+ }, null)]);
877
+ };
878
+ }
879
+ });
880
+ var index$3 = "";
881
+ const TimePicker = defineComponent({
882
+ props: {
883
+ time: {
884
+ type: Date
885
+ }
886
+ },
887
+ setup(props) {
888
+ const {
889
+ time = new Date()
890
+ } = props || {};
891
+ const state = reactive({
892
+ hour: time.getHours(),
893
+ minute: time.getMinutes(),
894
+ second: time.getSeconds()
895
+ });
896
+ const hours = Array(24).fill(0).map((_, i) => `${i}`.padStart(2, "0"));
897
+ const minutes = Array(60).fill(0).map((_, i) => `${i}`.padStart(2, "0"));
898
+ return () => {
899
+ return createVNode("div", {
900
+ "class": "devui-calendar-timepicker"
901
+ }, [createVNode("div", {
902
+ "class": "head"
903
+ }, [createVNode("div", {
904
+ "class": "chars"
905
+ }, [createVNode("span", null, [state.hour.toString().padStart(2, "0"), createTextVNode(":"), state.minute.toString().padStart(2, "0"), createTextVNode(":"), state.second.toString().padStart(2, "0")])])]), createVNode("div", {
906
+ "class": "select"
907
+ }, [createVNode(VerticalSlider, {
908
+ "items": hours,
909
+ "selectedIndex": state.hour,
910
+ "onChange": (_, idx) => state.hour = idx
911
+ }, null), createVNode(VerticalSlider, {
912
+ "items": minutes,
913
+ "selectedIndex": state.minute,
914
+ "onChange": (_, idx) => state.minute = idx
915
+ }, null), createVNode(VerticalSlider, {
916
+ "items": minutes,
917
+ "selectedIndex": state.second,
918
+ "onChange": (_, idx) => state.second = idx
919
+ }, null)])]);
920
+ };
921
+ }
922
+ });
923
+ var index$2 = "";
924
+ const Calendar = (props) => {
925
+ const {
926
+ showTime = false
927
+ } = props;
928
+ let {
929
+ current
930
+ } = props;
931
+ if (!(current instanceof Date)) {
932
+ current = new Date();
933
+ }
934
+ if (props.type === "range") {
935
+ let {
936
+ next
937
+ } = props;
938
+ if (!(next instanceof Date)) {
939
+ next = new Date(current.getFullYear(), current.getMonth() + 1, 1);
940
+ }
941
+ return createVNode("div", {
942
+ "class": "devui-calendar-container"
943
+ }, [createVNode(CalendarDatePanel, mergeProps(props, {
944
+ "pos": 0,
945
+ "current": current,
946
+ "compare": next
947
+ }), null), showTime ? createVNode(TimePicker, {
948
+ "time": current
949
+ }, null) : null, createVNode(CalendarDatePanel, mergeProps(props, {
950
+ "pos": 1,
951
+ "current": next,
952
+ "compare": current
953
+ }), null), showTime ? createVNode(TimePicker, {
954
+ "time": next
955
+ }, null) : null]);
956
+ } else {
957
+ return createVNode("div", {
958
+ "class": "devui-calendar-container"
959
+ }, [createVNode(CalendarDatePanel, mergeProps(props, {
960
+ "pos": 0,
961
+ "current": current
962
+ }), null), showTime ? createVNode(TimePicker, {
963
+ "time": current
964
+ }, null) : null]);
965
+ }
966
+ };
967
+ var datePicker = "";
968
+ const formatRange = (state) => {
969
+ const [start, end] = [state.start, state.end].sort((a, b) => a.getTime() - b.getTime());
970
+ state.start = start;
971
+ state.end = end;
972
+ if (compareDateSort(start, end, "m") !== 0) {
973
+ state.current = start;
974
+ state.next = end;
975
+ } else {
976
+ if (compareDateSort(start, state.current) < 0) {
977
+ state.current = start;
978
+ }
979
+ if (compareDateSort(state.next, end) < 0) {
980
+ state.next = end;
981
+ }
982
+ }
983
+ };
984
+ var DatePicker = defineComponent({
985
+ name: "DDatepicker",
986
+ props: {
987
+ selectedDateChange: {
988
+ type: Function
989
+ },
990
+ autoClose: {
991
+ type: Boolean,
992
+ default: false
993
+ },
994
+ range: {
995
+ type: Boolean,
996
+ default: false
997
+ },
998
+ showTime: {
999
+ type: Boolean,
1000
+ default: false
1001
+ },
1002
+ format: {
1003
+ type: String,
1004
+ default: "y/MM/dd"
1005
+ },
1006
+ rangeSpliter: {
1007
+ type: String,
1008
+ default: "-"
1009
+ },
1010
+ attachInputDom: {
1011
+ type: String
1012
+ },
1013
+ dateMin: {
1014
+ type: String
1015
+ },
1016
+ dateMax: {
1017
+ type: String
1018
+ }
1019
+ },
1020
+ setup(props) {
1021
+ const panel = ref(null);
1022
+ const input2 = ref(null);
1023
+ const current = parseDate(props.dateMin) || new Date();
1024
+ const next = new Date(current.getFullYear(), current.getMonth() + 1, 1);
1025
+ const state = reactive({
1026
+ show: false,
1027
+ value: "",
1028
+ placeholder: formatPlaceholder(props),
1029
+ current,
1030
+ next
1031
+ });
1032
+ state.value = formatValue(state, props);
1033
+ state.placeholder = formatPlaceholder(props);
1034
+ const documentClick = (e) => {
1035
+ e.stopPropagation();
1036
+ if (isIn(e.target, panel.value) || isIn(e.target, input2.value)) {
1037
+ return;
1038
+ }
1039
+ state.show = false;
1040
+ };
1041
+ onMounted(() => {
1042
+ document.addEventListener("click", documentClick);
1043
+ });
1044
+ onUnmounted(() => {
1045
+ document.removeEventListener("click", documentClick);
1046
+ });
1047
+ return () => {
1048
+ return createVNode("div", {
1049
+ "class": "devui-datepicker-container"
1050
+ }, [createVNode("div", {
1051
+ "class": "input-container",
1052
+ "ref": input2
1053
+ }, [createVNode(Input, {
1054
+ "ref": input2,
1055
+ "class": "datepicker-input",
1056
+ "modelValue": state.value,
1057
+ "placeholder": state.placeholder,
1058
+ "onFocus": () => state.show = true
1059
+ }, null), createVNode(Icon, {
1060
+ "size": "small",
1061
+ "name": "calendar",
1062
+ "class": "datepicker-input-icon"
1063
+ }, null)]), createVNode("div", {
1064
+ "class": "devui-datepicker-panel",
1065
+ "ref": panel
1066
+ }, [state.show ? createVNode(Calendar, {
1067
+ "type": props.range ? "range" : "select",
1068
+ "showTime": props.showTime,
1069
+ "current": state.current,
1070
+ "next": state.next,
1071
+ "dateMin": parseDate(props.dateMin),
1072
+ "dateMax": parseDate(props.dateMax),
1073
+ "dateStart": state.start,
1074
+ "dateEnd": state.end,
1075
+ "dateHover": state.hover,
1076
+ "onReset": (date) => {
1077
+ state.end = state.hover = void 0;
1078
+ state.start = date;
1079
+ },
1080
+ "onChange": () => {
1081
+ state.value = formatValue(state, props);
1082
+ state.placeholder = formatPlaceholder(props);
1083
+ invokeFunction(props.selectedDateChange, state.value);
1084
+ if (props.autoClose) {
1085
+ state.show = false;
1086
+ }
1087
+ },
1088
+ "onToday": (date) => {
1089
+ state.current = date;
1090
+ state.start = date;
1091
+ state.value = formatValue(state, props);
1092
+ state.placeholder = formatPlaceholder(props);
1093
+ invokeFunction(props.selectedDateChange, state.value);
1094
+ if (props.autoClose) {
1095
+ state.show = false;
1096
+ }
1097
+ },
1098
+ "onSelected": (date) => {
1099
+ state.start = date;
1100
+ if (compareDateSort(state.current, date) !== 0) {
1101
+ state.current = date;
1102
+ }
1103
+ },
1104
+ "onSelectStart": (date) => state.start = date,
1105
+ "onSelectEnd": (date) => {
1106
+ state.end = date;
1107
+ formatRange(state);
1108
+ },
1109
+ "onSelecting": (date) => state.hover = date,
1110
+ "onPreviousYear": (date, pos) => handleCalendarSwitchState(state, 0, pos, date),
1111
+ "onPreviousMonth": (date, pos) => handleCalendarSwitchState(state, 1, pos, date),
1112
+ "onNextMonth": (date, pos) => handleCalendarSwitchState(state, 2, pos, date),
1113
+ "onNextYear": (date, pos) => handleCalendarSwitchState(state, 3, pos, date)
1114
+ }, null) : null])]);
1115
+ };
1116
+ }
1117
+ });
1118
+ var index$1 = "";
1119
+ const StickSlider = defineComponent({
1120
+ name: "DStickSlider",
1121
+ props: {},
1122
+ setup() {
1123
+ const state = reactive({
1124
+ showButtons: false,
1125
+ selectedIndex: 0
1126
+ });
1127
+ const reset = () => {
1128
+ state.showButtons = false;
1129
+ };
1130
+ const handleMainButtonMouseDown = (e) => {
1131
+ e.stopPropagation();
1132
+ state.showButtons = true;
1133
+ };
1134
+ const handleMainButtonMouseUp = (e) => {
1135
+ e.stopPropagation();
1136
+ reset();
1137
+ };
1138
+ return () => {
1139
+ return createVNode("div", {
1140
+ "class": "devui-stick-slider",
1141
+ "onMousedown": handleMainButtonMouseDown,
1142
+ "onMouseup": handleMainButtonMouseUp,
1143
+ "onMouseleave": handleMainButtonMouseUp
1144
+ }, [createVNode("div", {
1145
+ "class": "sub-buttons",
1146
+ "style": {
1147
+ display: state.showButtons ? "" : "none"
1148
+ }
1149
+ }, [Array(16).fill(null).map((_, i) => {
1150
+ return createVNode("div", {
1151
+ "class": `button ${i === state.selectedIndex ? "selected" : ""}`,
1152
+ "onMouseenter": () => state.selectedIndex = i
1153
+ }, [i]);
1154
+ })]), createVNode("div", {
1155
+ "class": "main-button"
1156
+ }, null)]);
1157
+ };
1158
+ }
1159
+ });
1160
+ DatePicker.install = function(app) {
1161
+ app.component(DatePicker.name, DatePicker);
1162
+ app.component(StickSlider.name, StickSlider);
1163
+ };
1164
+ var index = {
1165
+ title: "DatePicker \u65E5\u671F\u9009\u62E9\u5668",
1166
+ category: "\u6570\u636E\u5F55\u5165",
1167
+ status: "50%",
1168
+ install(app) {
1169
+ app.use(DatePicker);
1170
+ }
1171
+ };
1172
+ export { DatePicker, StickSlider, index as default };