@hi-ui/hiui 2.15.11 → 2.15.12

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/es/_util/SwitchVersion.js +40 -0
  2. package/es/_util/depreactedPropsCompat.js +58 -0
  3. package/es/_util/index.js +31 -0
  4. package/es/_util/warning.js +2 -2
  5. package/es/alert/Alert.js +126 -0
  6. package/es/alert/__tests__/index.test.js +84 -0
  7. package/es/alert/index.js +6 -147
  8. package/es/alert/style/index.css +1 -1
  9. package/es/badge/Badge.js +82 -0
  10. package/es/badge/__tests__/index.test.js +82 -0
  11. package/es/badge/index.js +9 -87
  12. package/es/badge/style/index.css +1 -1
  13. package/es/badge/style/index.js +0 -0
  14. package/es/breadcrumb/__tests__/index.test.js +61 -0
  15. package/es/breadcrumb/index.js +85 -0
  16. package/es/breadcrumb/style/index.css +1 -0
  17. package/es/button/Button.js +62 -60
  18. package/es/button/ButtonGroup.js +24 -40
  19. package/es/button/IconLoading.js +6 -6
  20. package/es/button/__tests__/index.test.js +221 -0
  21. package/es/button/index.js +3 -2
  22. package/es/button/style/index.css +1 -1
  23. package/es/card/__tests__/index.test.js +179 -0
  24. package/es/card/index.js +61 -57
  25. package/es/card/style/index.css +1 -1
  26. package/es/carousel/__tests__/index.test.js +104 -0
  27. package/es/carousel/index.js +219 -0
  28. package/es/carousel/style/index.css +1 -0
  29. package/es/carousel/style/index.js +3 -0
  30. package/es/cascader/Cascader.js +190 -133
  31. package/es/cascader/Menu.js +168 -0
  32. package/es/cascader/__tests__/index.test.js +392 -0
  33. package/es/cascader/index.js +5 -2
  34. package/es/cascader/style/cascader.css +1 -1
  35. package/es/cascader/style/menu.css +1 -1
  36. package/es/checkbox/Checkbox.js +136 -0
  37. package/es/checkbox/Group.js +194 -0
  38. package/es/checkbox/__tests__/index.test.js +226 -0
  39. package/es/checkbox/checkbox-legacy/Base.js +212 -0
  40. package/es/checkbox/checkbox-legacy/CheckBox.js +157 -0
  41. package/es/checkbox/checkbox-legacy/index.js +15 -0
  42. package/es/checkbox/checkbox-legacy/style/index.css +1 -0
  43. package/es/checkbox/checkbox-legacy/style/index.js +3 -0
  44. package/es/checkbox/index.js +13 -4
  45. package/es/checkbox/style/index.css +1 -1
  46. package/es/collapse/__tests__/index.test.js +111 -0
  47. package/es/collapse/index.js +88 -110
  48. package/es/collapse/style/index.css +1 -1
  49. package/es/confirm/index.js +39 -60
  50. package/es/context/index.js +45 -51
  51. package/es/counter/Counter.js +339 -0
  52. package/es/counter/__tests__/index.test.js +134 -0
  53. package/es/counter/counter-legacy/index.js +267 -0
  54. package/es/counter/index.js +6 -270
  55. package/es/counter/style/index.css +1 -1
  56. package/es/date-picker/BasePicker.js +380 -302
  57. package/es/date-picker/Calender.js +326 -98
  58. package/es/date-picker/DatePanel.js +194 -213
  59. package/es/date-picker/DatePicker.js +143 -47
  60. package/es/date-picker/DateRangePanel.js +272 -208
  61. package/es/date-picker/Modal.js +18 -32
  62. package/es/date-picker/Time.js +231 -345
  63. package/es/date-picker/TimeList.js +246 -0
  64. package/es/date-picker/TimePanel.js +28 -41
  65. package/es/date-picker/TimePeriodPanel.js +27 -46
  66. package/es/date-picker/TimePicker.js +44 -46
  67. package/es/date-picker/TimeRangePanel.js +33 -51
  68. package/es/date-picker/Type.js +5 -1
  69. package/es/date-picker/WeekRangePanel.js +254 -175
  70. package/es/date-picker/YMRangePanel.js +364 -0
  71. package/es/date-picker/__tests__/index.test.js +956 -0
  72. package/es/date-picker/constants.js +14 -28
  73. package/es/date-picker/dateUtil.js +221 -52
  74. package/es/date-picker/datepicker-legacy/BasePicker.js +511 -0
  75. package/es/date-picker/datepicker-legacy/Calender.js +422 -0
  76. package/es/date-picker/datepicker-legacy/DatePanel.js +455 -0
  77. package/es/date-picker/datepicker-legacy/DatePicker.js +103 -0
  78. package/es/date-picker/datepicker-legacy/DateRangePanel.js +488 -0
  79. package/es/date-picker/datepicker-legacy/Modal.js +67 -0
  80. package/es/date-picker/datepicker-legacy/Time.js +405 -0
  81. package/es/date-picker/datepicker-legacy/TimePanel.js +85 -0
  82. package/es/date-picker/datepicker-legacy/TimePeriodPanel.js +118 -0
  83. package/es/date-picker/datepicker-legacy/TimePicker.js +78 -0
  84. package/es/date-picker/datepicker-legacy/TimeRangePanel.js +90 -0
  85. package/es/date-picker/datepicker-legacy/Type.js +31 -0
  86. package/es/date-picker/datepicker-legacy/WeekRangePanel.js +337 -0
  87. package/es/date-picker/datepicker-legacy/constants.js +79 -0
  88. package/es/date-picker/datepicker-legacy/dateUtil.js +258 -0
  89. package/es/date-picker/datepicker-legacy/index.js +15 -0
  90. package/es/date-picker/datepicker-legacy/local.js +11 -0
  91. package/es/date-picker/datepicker-legacy/style/index.css +1 -0
  92. package/es/date-picker/datepicker-legacy/style/index.js +3 -0
  93. package/es/date-picker/datepicker-legacy/style/timepicker.css +1 -0
  94. package/es/date-picker/datepicker-legacy/util.js +60 -0
  95. package/es/date-picker/index.js +5 -2
  96. package/es/date-picker/style/index.css +1 -1
  97. package/es/date-picker/toLunar.js +172 -0
  98. package/es/date-picker/util.js +101 -8
  99. package/es/dropdown/Dropdown.js +191 -203
  100. package/es/dropdown/DropdownButton.js +102 -0
  101. package/es/dropdown/DropdownMenu.js +107 -0
  102. package/es/dropdown/DropdownMenuItem.js +172 -0
  103. package/es/dropdown/__tests__/index.test.js +313 -0
  104. package/es/dropdown/index.js +69 -4
  105. package/es/dropdown/style/index.css +1 -1
  106. package/es/dropdown/style/index.js +0 -2
  107. package/es/dropdown/{__test__ → tests}/index.test.js +7 -7
  108. package/es/dropdown/utils.js +35 -0
  109. package/es/ficon/index.js +16 -30
  110. package/es/form/Form.js +176 -0
  111. package/es/form/{item.js → Item.js} +52 -60
  112. package/es/form/__tests__/index.test.js +571 -0
  113. package/es/form/index.js +6 -171
  114. package/es/form/style/index.css +1 -1
  115. package/es/grid/__tests__/index.test.js +100 -0
  116. package/es/grid/index.js +36 -56
  117. package/es/icon/index.js +23 -38
  118. package/es/index.js +61 -9
  119. package/es/input/Input.js +400 -0
  120. package/es/input/__tests__/index.test.js +376 -0
  121. package/es/input/index.js +26 -347
  122. package/es/input/input-legacy/index.js +341 -0
  123. package/es/input/input-legacy/util.js +176 -0
  124. package/es/input/style/index.css +1 -1
  125. package/es/input/util.js +26 -18
  126. package/es/lib/withDragDropContext.js +2 -2
  127. package/es/loading/Loading.js +173 -0
  128. package/es/loading/__tests__/index.test.js +110 -0
  129. package/es/loading/index.js +5 -129
  130. package/es/loading/style/index.css +0 -0
  131. package/es/loading/style/index.js +0 -0
  132. package/es/locales/en-US.js +45 -9
  133. package/es/locales/index.js +16 -2
  134. package/es/locales/zh-CN.js +46 -10
  135. package/es/locales/zh-Hant-HK.js +123 -0
  136. package/es/locales/zh-Hant-TW.js +125 -0
  137. package/es/menu/Item.js +34 -51
  138. package/es/menu/Menu.js +414 -0
  139. package/es/menu/SubMenu.js +63 -90
  140. package/es/menu/Title.js +37 -51
  141. package/es/menu/__tests__/index.test.js +274 -0
  142. package/es/menu/index.js +12 -419
  143. package/es/menu/style/index.css +1 -1
  144. package/es/message/__tests__/index.test.js +71 -0
  145. package/es/message/index.js +58 -0
  146. package/es/message/style/index.css +1 -0
  147. package/es/message/style/index.js +5 -0
  148. package/es/modal/__tests__/index.test.js +178 -0
  149. package/es/modal/index.js +85 -77
  150. package/es/modal/style/index.css +1 -1
  151. package/es/nav-menu/NavMenu.js +44 -61
  152. package/es/nav-menu/__test__/index.test.js +8 -8
  153. package/es/nav-menu/__tests__/index.test.js +23 -0
  154. package/es/nav-menu/index.js +2 -2
  155. package/es/notice/Notice.js +136 -0
  156. package/es/notice/NoticeContainer.js +107 -0
  157. package/es/notice/__tests__/index.test.js +174 -0
  158. package/es/notice/index.js +66 -0
  159. package/es/notice/style/index.css +1 -0
  160. package/es/notice/style/index.js +5 -0
  161. package/es/notification/HandleNotification/index.js +216 -0
  162. package/es/notification/HandleNotification/style/index.css +1 -0
  163. package/es/notification/HandleNotification/style/index.js +5 -0
  164. package/es/notification/__tests__/index.test.js +114 -0
  165. package/es/notification/index.js +68 -231
  166. package/es/notification/style/index.css +1 -1
  167. package/es/notification/style/index.js +0 -0
  168. package/es/pagination/Pager.js +7 -9
  169. package/es/pagination/Pagination.js +134 -133
  170. package/es/pagination/__tests__/index.test.js +244 -0
  171. package/es/pagination/index.js +9 -8
  172. package/es/pagination/style/index.css +1 -1
  173. package/es/panel/index.js +28 -46
  174. package/es/popover/__test__/index.test.js +10 -10
  175. package/es/popover/__tests__/index.test.js +152 -0
  176. package/es/popover/index.js +77 -83
  177. package/es/popper/index.js +68 -64
  178. package/es/popper/style/index.css +1 -1
  179. package/es/preview/index.js +529 -0
  180. package/es/preview/style/index.css +1 -0
  181. package/es/preview/style/index.js +3 -0
  182. package/es/progress/BarProgress.js +107 -43
  183. package/es/progress/CircleProgress.js +13 -14
  184. package/es/progress/DashboardProgress.js +11 -13
  185. package/es/progress/Progress.js +102 -0
  186. package/es/progress/__tests__/index.test.js +131 -0
  187. package/es/progress/index.js +8 -100
  188. package/es/progress/style/index.css +1 -1
  189. package/es/radio/Group.js +199 -0
  190. package/es/radio/Radio.js +147 -0
  191. package/es/radio/__tests__/index.test.js +127 -0
  192. package/es/radio/index.js +10 -216
  193. package/es/radio/{__test__ → radio-legacy/__test__}/index.test.js +13 -13
  194. package/es/radio/radio-legacy/index.js +214 -0
  195. package/es/radio/radio-legacy/style/index.css +1 -0
  196. package/es/radio/radio-legacy/style/index.js +3 -0
  197. package/es/radio/style/index.css +1 -1
  198. package/es/rate/Icons.js +70 -70
  199. package/es/rate/Rate.js +75 -108
  200. package/es/rate/__tests__/index.test.js +124 -0
  201. package/es/rate/index.js +5 -2
  202. package/es/rate/style/index.css +1 -1
  203. package/es/select/Select.js +330 -265
  204. package/es/select/SelectDropdown.js +223 -79
  205. package/es/select/SelectInput.js +120 -91
  206. package/es/select/__tests__/index.test.js +505 -0
  207. package/es/select/index.js +6 -4
  208. package/es/select/select-legacy/Option.js +78 -0
  209. package/es/select/select-legacy/Select.js +702 -0
  210. package/es/select/select-legacy/SelectDropdown.js +157 -0
  211. package/es/select/select-legacy/SelectInput.js +308 -0
  212. package/es/select/select-legacy/common.js +19 -0
  213. package/es/select/select-legacy/index.js +16 -0
  214. package/es/select/style/select-dropdown.css +1 -1
  215. package/es/select/style/select-input.css +1 -1
  216. package/es/stepper/Stepper.js +147 -0
  217. package/es/stepper/__tests__/index.test.js +161 -0
  218. package/es/stepper/index.js +21 -127
  219. package/es/stepper/style/index.css +1 -1
  220. package/es/style/icon/diyIcon.css +1 -1
  221. package/es/style/icon/index.css +1 -1
  222. package/es/switch/__tests__/index.test.js +68 -0
  223. package/es/switch/index.js +26 -46
  224. package/es/switch/style/index.css +1 -1
  225. package/es/table/Body.js +294 -0
  226. package/es/table/ClickOuterside.js +95 -0
  227. package/es/table/Footer.js +171 -0
  228. package/es/table/Header.js +320 -0
  229. package/es/table/TableContent.js +101 -0
  230. package/es/table/__tests__/index.test.js +129 -0
  231. package/es/table/checkbox/index.js +36 -47
  232. package/es/table/checkbox/style/index.css +1 -0
  233. package/es/table/checkbox/style/index.js +3 -0
  234. package/es/table/index.js +269 -314
  235. package/es/table/menu/index.js +34 -44
  236. package/es/table/prefix.js +2 -2
  237. package/es/table/style/Table.css +1 -1
  238. package/es/table/style/index.css +1 -1
  239. package/es/tabs/ItemDropdown.js +45 -65
  240. package/es/tabs/TabPane.js +26 -44
  241. package/es/tabs/Tabs.js +110 -111
  242. package/es/tabs/__tests__/index.test.js +329 -0
  243. package/es/tabs/index.js +9 -3
  244. package/es/tabs/style/index.css +1 -1
  245. package/es/tabs/tabs-legacy/ItemDropdown.js +162 -0
  246. package/es/tabs/tabs-legacy/TabPane.js +70 -0
  247. package/es/tabs/tabs-legacy/Tabs.js +291 -0
  248. package/es/tabs/tabs-legacy/index.js +18 -0
  249. package/es/tabs/tabs-legacy/style/index.css +1 -0
  250. package/es/tabs/tabs-legacy/style/index.js +3 -0
  251. package/es/tag/__tests__/index.test.js +46 -0
  252. package/es/tag/index.js +86 -0
  253. package/es/tag/style/index.css +1 -0
  254. package/es/tag/style/index.js +3 -0
  255. package/es/timeline/__tests__/index.test.js +198 -0
  256. package/es/timeline/index.js +206 -136
  257. package/es/timeline/style/index.css +1 -1
  258. package/es/tooltip/__tests__/index.test.js +166 -0
  259. package/es/tooltip/index.js +93 -52
  260. package/es/tooltip/style/index.css +1 -1
  261. package/es/transfer/Item.js +73 -71
  262. package/es/transfer/Transfer.js +558 -0
  263. package/es/transfer/__tests__/index.test.js +210 -0
  264. package/es/transfer/index.js +4 -443
  265. package/es/transfer/style/index.css +1 -1
  266. package/es/tree/IconLoading.js +38 -0
  267. package/es/tree/Tree.js +94 -111
  268. package/es/tree/TreeDivider.js +6 -6
  269. package/es/tree/TreeItem.js +217 -123
  270. package/es/tree/TreeNode.js +472 -333
  271. package/es/tree/__tests__/index.test.js +599 -0
  272. package/es/tree/index.js +9 -2
  273. package/es/tree/style/index.css +1 -1
  274. package/es/tree/tree-legacy/Tree.js +330 -0
  275. package/es/tree/tree-legacy/TreeDivider.js +25 -0
  276. package/es/tree/tree-legacy/TreeItem.js +326 -0
  277. package/es/tree/tree-legacy/TreeNode.js +711 -0
  278. package/es/tree/tree-legacy/index.js +13 -0
  279. package/es/tree/tree-legacy/style/index.css +1 -0
  280. package/es/tree/tree-legacy/style/index.js +3 -0
  281. package/es/tree/tree-legacy/util.js +434 -0
  282. package/es/tree/util.js +8 -256
  283. package/es/upload/Upload.js +292 -200
  284. package/es/upload/UploadAvatar.js +61 -79
  285. package/es/upload/UploadClick.js +62 -60
  286. package/es/upload/UploadDrag.js +63 -66
  287. package/es/upload/UploadPhoto.js +86 -75
  288. package/es/upload/UploadPictureCard.js +53 -60
  289. package/es/upload/__tests__/index.test.js +760 -0
  290. package/es/upload/index.js +8 -71
  291. package/es/upload/main.js +83 -0
  292. package/es/upload/style/index.css +1 -1
  293. package/es/upload/tool.js +0 -1
  294. package/es/upload/{Preview.js → upload-legacy/Preview.js} +48 -62
  295. package/es/upload/upload-legacy/Upload.js +431 -0
  296. package/es/upload/upload-legacy/UploadAvatar.js +318 -0
  297. package/es/upload/upload-legacy/UploadClick.js +121 -0
  298. package/es/upload/upload-legacy/UploadDrag.js +176 -0
  299. package/es/upload/upload-legacy/UploadPhoto.js +179 -0
  300. package/es/upload/upload-legacy/UploadPictureCard.js +122 -0
  301. package/es/upload/upload-legacy/index.js +67 -0
  302. package/es/upload/upload-legacy/style/index.css +1 -0
  303. package/es/upload/upload-legacy/style/index.js +5 -0
  304. package/es/upload/upload-legacy/tool.js +84 -0
  305. package/es/watermark/index.js +97 -0
  306. package/es/watermark/watermark.js +263 -0
  307. package/package.json +1 -1
  308. package/es/alert/__test__/index.test.js +0 -67
  309. package/es/button/__test__/index.test.js +0 -29
  310. package/es/cascader/__test__/index.test.js +0 -283
  311. package/es/cascader/menu.js +0 -155
  312. package/es/checkbox/Base.js +0 -205
  313. package/es/checkbox/CheckBox.js +0 -185
  314. package/es/collapse/__test__/index.test.js +0 -58
  315. package/es/counter/__test__/index.test.js +0 -52
  316. package/es/menu/ItemGroup.js +0 -81
  317. package/es/modal/__test__/index.test.js +0 -123
  318. package/es/notification/__test__/index.test.js +0 -56
  319. package/es/pagination/__test__/index.test.js +0 -140
  320. package/es/rate/__test__/index.test.js +0 -54
  321. package/es/select/Option.js +0 -93
  322. package/es/select/__test__/index.test.js +0 -429
  323. package/es/style/color/colors.css +0 -0
  324. package/es/style/index.css +0 -0
  325. package/es/style/mixins/colors.css +0 -0
  326. package/es/style/mixins/index.css +0 -0
  327. package/es/style/theme/dark.css +0 -0
  328. package/es/style/theme/default.css +0 -0
  329. package/es/switch/__test__/index.test.js +0 -39
  330. package/es/table/__test__/index.test.js +0 -73
  331. package/es/table/body.js +0 -318
  332. package/es/table/clickOuterside.js +0 -115
  333. package/es/table/footer.js +0 -196
  334. package/es/table/header.js +0 -337
  335. package/es/table/pover.js +0 -154
  336. package/es/table/tableContent.js +0 -120
  337. package/es/timeline/__test__/index.test.js +0 -49
  338. package/es/timeline/foldingItem.js +0 -82
  339. package/es/tooltip/__test__/index.test.js +0 -67
  340. package/es/transfer/__test__/index.test.js +0 -11
  341. /package/es/{style → breadcrumb/style}/index.js +0 -0
  342. /package/es/checkbox/{common.js → checkbox-legacy/common.js} +0 -0
  343. /package/es/upload/{style → upload-legacy/style}/preview.css +0 -0
  344. /package/es/upload/{style → upload-legacy/style}/preview.js +0 -0
@@ -1,19 +1,35 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
+
3
7
  Object.defineProperty(exports, "__esModule", {
4
8
  value: true
5
9
  });
6
10
  exports["default"] = void 0;
7
11
 
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
20
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
+
8
22
  var _react = _interopRequireWildcard(require("react"));
9
23
 
24
+ var _lodash = _interopRequireDefault(require("lodash"));
25
+
10
26
  var _Modal = _interopRequireDefault(require("./Modal"));
11
27
 
12
28
  var _classnames = _interopRequireDefault(require("classnames"));
13
29
 
14
30
  var _constants = require("./constants");
15
31
 
16
- var _lodash = _interopRequireDefault(require("lodash"));
32
+ var _util = require("./util");
17
33
 
18
34
  var _propTypes = _interopRequireDefault(require("prop-types"));
19
35
 
@@ -21,87 +37,60 @@ var _Type = _interopRequireDefault(require("./Type"));
21
37
 
22
38
  var _dateUtil = require("./dateUtil");
23
39
 
24
- var _dateFns = require("date-fns");
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
29
-
30
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
-
32
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
33
-
34
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
40
+ function noop() {}
35
41
 
36
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
-
38
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
39
-
40
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
41
-
42
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
43
-
44
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
45
-
46
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
47
-
48
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
49
-
50
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
51
-
52
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
53
-
54
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
55
-
56
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
57
-
58
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
59
-
60
- var BasePicker = /*#__PURE__*/function (_Component) {
61
- _inherits(BasePicker, _Component);
62
-
63
- var _super = _createSuper(BasePicker);
42
+ var BasePicker =
43
+ /*#__PURE__*/
44
+ function (_Component) {
45
+ (0, _inherits2["default"])(BasePicker, _Component);
64
46
 
65
47
  function BasePicker(props) {
66
48
  var _this;
67
49
 
68
- _classCallCheck(this, BasePicker);
69
-
70
- _this = _super.call(this, props);
71
-
72
- _defineProperty(_assertThisInitialized(_this), "inputRoot", null);
73
-
74
- _defineProperty(_assertThisInitialized(_this), "input", null);
75
-
76
- _defineProperty(_assertThisInitialized(_this), "rInput", null);
77
-
50
+ (0, _classCallCheck2["default"])(this, BasePicker);
51
+ _this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(BasePicker).call(this, props));
78
52
  _this.state = {
79
53
  showPanel: false,
80
54
  style: {},
81
55
  date: null,
82
56
  isFocus: false,
83
- // input 框内的显示的时间内容
84
57
  texts: ['', ''],
85
58
  placeholder: '',
86
- rText: '',
87
59
  leftPlaceholder: '',
88
60
  rightPlaceholder: '',
89
- format: ''
61
+ format: _this.getFormatString(props),
62
+ rangeInputIsError: false
90
63
  };
64
+ _this.inputRoot = _react["default"].createRef();
65
+ _this.input = null;
66
+ _this.rInput = null;
91
67
  return _this;
92
68
  }
93
69
 
94
- _createClass(BasePicker, [{
70
+ (0, _createClass2["default"])(BasePicker, [{
95
71
  key: "setPlaceholder",
96
- value: function setPlaceholder() {
72
+ value: function setPlaceholder(_props) {
73
+ var placeholder = _props.placeholder;
97
74
  var _this$props = this.props,
98
- placeholder = _this$props.placeholder,
99
75
  localeDatas = _this$props.localeDatas,
100
- type = _this$props.type;
101
- var tempPlaceholder = localeDatas.datePicker.placeholders[type] || localeDatas.datePicker.placeholder;
76
+ type = _this$props.type,
77
+ showTime = _this$props.showTime;
78
+ var typePlaceholder = localeDatas.datePicker.placeholders[type];
79
+ var tempPlaceholder = showTime ? localeDatas.datePicker.placeholderTimeperiod : typePlaceholder || localeDatas.datePicker.placeholder;
102
80
  var leftPlaceholder = tempPlaceholder;
103
81
  var rightPlaceholder = tempPlaceholder;
104
82
 
83
+ if (typePlaceholder instanceof Array) {
84
+ if (showTime) {
85
+ var timeperiodPlaceholder = localeDatas.datePicker.placeholders.timeperiod;
86
+ leftPlaceholder = timeperiodPlaceholder[0];
87
+ rightPlaceholder = timeperiodPlaceholder[1];
88
+ } else {
89
+ leftPlaceholder = tempPlaceholder[0];
90
+ rightPlaceholder = tempPlaceholder[1];
91
+ }
92
+ }
93
+
105
94
  if (placeholder instanceof Array) {
106
95
  leftPlaceholder = placeholder[0];
107
96
  rightPlaceholder = placeholder[1] || placeholder[0];
@@ -115,94 +104,13 @@ var BasePicker = /*#__PURE__*/function (_Component) {
115
104
  rightPlaceholder: rightPlaceholder
116
105
  });
117
106
  }
118
- }, {
119
- key: "_parseProps",
120
- value: function _parseProps(props, callback) {
121
- var _this2 = this;
122
-
123
- var value = props.value,
124
- showTime = props.showTime,
125
- type = props.type,
126
- format = props.format,
127
- localeDatas = props.localeDatas,
128
- weekOffset = props.weekOffset;
129
- format = format || _constants.FORMATS[type];
130
- var date;
131
- var noText = false;
132
- /**
133
- * value 可能的格式:
134
- * '' | undefined | null | Date | String | Number | {start: xxx, end: xxx}
135
- */
136
-
137
- if (value === '' || !value) {
138
- // value 未传入情况
139
- date = new Date();
140
- noText = true;
141
- }
142
-
143
- if (typeof value === 'number' || typeof value === 'string' && value.trim().length > 4) {
144
- // value 为数字(times)
145
- date = (0, _dateUtil.parse)(value);
146
- }
147
-
148
- if (value instanceof Date) {
149
- date = value;
150
- }
151
-
152
- if (type.includes('range') || type === 'timeperiod') {
153
- if (value) {
154
- if (value instanceof Date) {
155
- // 如果为时间段选择,则取默认的第一个范围
156
- date = {
157
- startDate: (0, _dateUtil.startOfDay)(date),
158
- endDate: type === 'timeperiod' ? (0, _dateFns.addHours)((0, _dateUtil.startOfDay)(date), 4) : (0, _dateUtil.endOfDay)(date)
159
- };
160
- }
161
-
162
- if (value.start && value.end) {
163
- date = {
164
- startDate: value.start,
165
- endDate: value.end
166
- };
167
- }
168
- } else {
169
- date = {
170
- startDate: new Date(),
171
- endDate: new Date()
172
- };
173
- }
174
- }
175
-
176
- var leftText = noText ? '' : (0, _constants.formatterDate)(type, date.startDate || date, format, showTime, localeDatas, weekOffset);
177
- var rightText = noText ? '' : (0, _constants.formatterDate)(type, date.endDate || date, format, showTime, localeDatas, weekOffset);
178
- this.setState({
179
- texts: [leftText, rightText],
180
- date: date,
181
- format: format
182
- }, function () {
183
- callback && callback(_this2.state.date);
184
- });
185
- }
186
107
  }, {
187
108
  key: "componentDidMount",
188
109
  value: function componentDidMount() {
189
- var _this3 = this;
110
+ this._parseProps(this.props);
190
111
 
191
- this._parseProps(this.props, function (date) {
192
- if (date && date.startDate && date.endDate) {
193
- date = {
194
- start: new Date(date.startDate),
195
- end: new Date(date.endDate)
196
- };
197
- } else if (date !== null) {
198
- date = new Date(date);
199
- }
200
-
201
- _this3.props.value && _this3.props.onChange && _this3.props.onChange(date);
202
- });
203
-
204
- this.setPlaceholder();
205
- var rect = this.inputRoot.getBoundingClientRect();
112
+ this.setPlaceholder(this.props);
113
+ var rect = this.inputRoot.current.getBoundingClientRect();
206
114
  this.calcPanelPos(rect);
207
115
  }
208
116
  }, {
@@ -214,12 +122,20 @@ var BasePicker = /*#__PURE__*/function (_Component) {
214
122
 
215
123
  var _w = type.indexOf('range') !== -1 ? 578 : 288;
216
124
 
125
+ if (type === 'timerange') {
126
+ _w = 400;
127
+ }
128
+
217
129
  var _h = 298;
218
130
 
219
131
  if (type === 'daterange' && showTime) {
220
132
  _h = 344;
221
133
  }
222
134
 
135
+ if ((0, _util.showLargeCalendar)(this.props)) {
136
+ _h = 440;
137
+ }
138
+
223
139
  var _cw = document.documentElement.clientWidth || document.body.clientWidth;
224
140
 
225
141
  var _ch = document.documentElement.clientHeight || document.body.clientHeight;
@@ -231,14 +147,14 @@ var BasePicker = /*#__PURE__*/function (_Component) {
231
147
  top = rect.top,
232
148
  height = rect.height;
233
149
 
234
- var _top = rect.top + rect.height + _st;
150
+ var _top = rect.top + rect.height + _st + 4;
235
151
 
236
152
  if (left + _w > _cw) {
237
153
  left = left + width - _w;
238
154
  }
239
155
 
240
156
  if (top + _h + height > _ch) {
241
- _top = top - _h + _st;
157
+ _top = top - _h + _st - 4;
242
158
  }
243
159
 
244
160
  this.setState({
@@ -252,141 +168,234 @@ var BasePicker = /*#__PURE__*/function (_Component) {
252
168
  }, {
253
169
  key: "componentWillReceiveProps",
254
170
  value: function componentWillReceiveProps(nextProps) {
171
+ if (nextProps.value !== this.props.value) {
172
+ this._parseProps(nextProps);
173
+ }
174
+
175
+ if (!_lodash["default"].isEqual(nextProps.placeholder, this.props.placeholder)) {
176
+ this.setPlaceholder(nextProps);
177
+ }
178
+ }
179
+ }, {
180
+ key: "getFormatString",
181
+ value: function getFormatString(props) {
182
+ var format = props.format,
183
+ showTime = props.showTime,
184
+ type = props.type;
185
+ format = (0, _dateUtil.compatibleFormatString)(format || _constants.FORMATS[type]);
186
+
187
+ if ((showTime || type === 'timeperiod') && !/[H|h|m|s]/.test(format)) {
188
+ format = format + ' HH:mm:ss';
189
+ }
190
+
191
+ return format;
192
+ }
193
+ }, {
194
+ key: "callFormatterDate",
195
+ value: function callFormatterDate(date) {
255
196
  var _this$props3 = this.props,
256
- onChange = _this$props3.onChange,
257
- currentProps = _objectWithoutProperties(_this$props3, ["onChange"]);
197
+ type = _this$props3.type,
198
+ showTime = _this$props3.showTime,
199
+ localeDatas = _this$props3.localeDatas,
200
+ weekOffset = _this$props3.weekOffset;
201
+ return (0, _constants.formatterDate)(type, date, this.state.format, showTime, localeDatas, weekOffset);
202
+ }
203
+ }, {
204
+ key: "_parseProps",
205
+ value: function _parseProps(props) {
206
+ var value = props.value,
207
+ defaultValue = props.defaultValue,
208
+ type = props.type,
209
+ _props$timeInterval = props.timeInterval,
210
+ timeInterval = _props$timeInterval === void 0 ? 240 : _props$timeInterval;
211
+ var format = this.state.format;
258
212
 
259
- var _onChange = nextProps.onChange,
260
- _nextProps = _objectWithoutProperties(nextProps, ["onChange"]);
213
+ var _value = value || defaultValue;
261
214
 
262
- if (!_lodash["default"].isEqual(currentProps, _nextProps)) {
263
- this._parseProps(nextProps);
215
+ var start;
216
+ var end;
217
+ var date;
218
+ var leftText = '';
219
+ var rightText = '';
220
+
221
+ if (_value) {
222
+ if (Object.prototype.toString.call(_value) === '[object Object]') {
223
+ start = (0, _dateUtil.compatibleToDate)(_value.start, format);
224
+ end = (0, _dateUtil.compatibleToDate)(_value.end, format);
225
+ } else {
226
+ start = (0, _dateUtil.compatibleToDate)(_value, format);
227
+
228
+ if (type.includes('range')) {
229
+ end = (0, _dateUtil.compatibleToDate)(start, format);
230
+
231
+ if (type === 'weekrange') {
232
+ start = (0, _dateUtil.startOfWeek)(start);
233
+ end = (0, _dateUtil.endOfWeek)(end);
234
+ }
235
+ }
236
+ }
237
+
238
+ if (type === 'timeperiod' && (0, _dateUtil.isValid)(start)) {
239
+ var startTime = start.getTime();
240
+ startTime += timeInterval * 60 * 1000;
241
+ end = new Date(startTime);
242
+ }
264
243
  }
244
+
245
+ date = {
246
+ startDate: (0, _dateUtil.compatibleToDate)(start, format),
247
+ endDate: (0, _dateUtil.compatibleToDate)(end, format)
248
+ };
249
+ leftText = (0, _dateUtil.isValid)(date.startDate) ? this.callFormatterDate(date.startDate) : '';
250
+ rightText = (0, _dateUtil.isValid)(date.endDate) ? this.callFormatterDate(date.endDate) : '';
251
+ this.setState({
252
+ texts: [leftText, rightText],
253
+ date: date
254
+ });
265
255
  }
266
256
  }, {
267
257
  key: "onPick",
268
258
  value: function onPick(date, showPanel) {
269
- var _this4 = this;
259
+ var _this2 = this;
260
+
261
+ if (!date.startDate) {
262
+ date = {
263
+ startDate: date,
264
+ endDate: undefined
265
+ };
266
+ }
270
267
 
271
- var _this$props4 = this.props,
272
- type = _this$props4.type,
273
- showTime = _this$props4.showTime,
274
- localeDatas = _this$props4.localeDatas,
275
- weekOffset = _this$props4.weekOffset;
276
- var format = this.state.format;
277
268
  this.setState({
278
269
  date: date,
279
- texts: [(0, _constants.formatterDate)(type, date.startDate || date, format, showTime, localeDatas, weekOffset), (0, _constants.formatterDate)(type, date.endDate, format, showTime, localeDatas, weekOffset)],
270
+ texts: [this.callFormatterDate(date.startDate), this.callFormatterDate(date.endDate)],
280
271
  showPanel: showPanel,
281
272
  isFocus: false
282
273
  }, function () {
283
274
  if (!showPanel) {
284
- _this4.callback();
275
+ _this2.callback();
285
276
  }
286
277
  });
287
278
  }
288
279
  }, {
289
280
  key: "callback",
290
281
  value: function callback() {
291
- var _this$props5 = this.props,
292
- type = _this$props5.type,
293
- onChange = _this$props5.onChange,
294
- weekOffset = _this$props5.weekOffset;
295
- var date = this.state.date;
296
-
297
- if (onChange) {
298
- var _weekOffset = {
299
- weekStartsOn: weekOffset
300
- };
282
+ var _this$props4 = this.props,
283
+ type = _this$props4.type,
284
+ onChange = _this$props4.onChange,
285
+ disabled = _this$props4.disabled,
286
+ max = _this$props4.max,
287
+ min = _this$props4.min;
288
+ var _this$state = this.state,
289
+ date = _this$state.date,
290
+ format = _this$state.format;
291
+
292
+ if (onChange && !disabled) {
293
+ var _getInRangeDate = (0, _util.getInRangeDate)(_lodash["default"].cloneDeep(date.startDate), _lodash["default"].cloneDeep(date.endDate), max, min),
294
+ startDate = _getInRangeDate.startDate,
295
+ endDate = _getInRangeDate.endDate;
301
296
 
302
- if (type === 'week') {
303
- onChange({
304
- start: (0, _dateUtil.startOfWeek)(date, _weekOffset),
305
- end: (0, _dateUtil.endOfWeek)(date, _weekOffset)
297
+ startDate = (0, _dateUtil.isValid)(startDate) ? startDate : '';
298
+ endDate = (0, _dateUtil.isValid)(endDate) ? endDate : '';
299
+
300
+ if (type === 'week' || type === 'weekrange') {
301
+ this.setState({
302
+ texts: [this.callFormatterDate(startDate), this.callFormatterDate(endDate)],
303
+ showPanel: false
306
304
  });
305
+ onChange(date);
307
306
  return;
308
307
  }
309
308
 
310
- if (date && date.startDate && date.endDate) {
311
- if (type === 'weekrange') {
312
- onChange({
313
- start: (0, _dateUtil.startOfWeek)(date.startDate, _weekOffset),
314
- end: (0, _dateUtil.endOfWeek)(date.endDate, _weekOffset)
315
- });
316
- } else if (['timerange', 'timeperiod', 'daterange'].includes(type)) {
317
- onChange({
318
- start: date.startDate,
319
- end: date.endDate
320
- });
321
- } else {
322
- onChange({
323
- start: (0, _dateUtil.startOfDay)(date.startDate),
324
- end: (0, _dateUtil.endOfDay)(date.endDate)
325
- });
326
- }
327
- } else {
328
- onChange(date);
309
+ if (type === 'time') {
310
+ this.setState({
311
+ texts: [this.callFormatterDate(startDate), ''],
312
+ showPanel: false
313
+ });
314
+ onChange(startDate, (0, _dateUtil.dateFormat)(startDate, format));
315
+ return;
329
316
  }
330
- }
331
- }
332
- }, {
333
- key: "timeConfirm",
334
- value: function timeConfirm(date, onlyTime) {
335
- var _this$props6 = this.props,
336
- type = _this$props6.type,
337
- showTime = _this$props6.showTime,
338
- onChange = _this$props6.onChange,
339
- localeDatas = _this$props6.localeDatas,
340
- weekOffset = _this$props6.weekOffset;
341
- var format = this.state.format;
342
- onlyTime && (format = _constants.FORMATS['time']);
343
- this.setState({
344
- date: date,
345
- texts: [(0, _constants.formatterDate)(type, date.startDate || date, format, showTime, localeDatas, weekOffset), (0, _constants.formatterDate)(type, date.endDate, format, showTime, localeDatas, weekOffset)],
346
- showPanel: false,
347
- isFocus: false
348
- });
349
317
 
350
- if (onChange) {
351
- if (date.startDate && date.endDate) {
352
- onChange({
353
- start: date.startDate,
354
- end: date.endDate
318
+ if (['timerange', 'timeperiod', 'daterange', 'yearrange', 'monthrange'].includes(type)) {
319
+ var isError = Date.parse((0, _dateUtil.toDate)(startDate)) > Date.parse((0, _dateUtil.toDate)(endDate));
320
+ this.setState({
321
+ rangeInputIsError: isError,
322
+ texts: [this.callFormatterDate(startDate), this.callFormatterDate(endDate)],
323
+ showPanel: isError
355
324
  });
356
- } else {
357
- onChange(date);
325
+ !isError && onChange({
326
+ start: startDate,
327
+ end: endDate
328
+ }, {
329
+ start: (0, _dateUtil.dateFormat)(startDate, format),
330
+ end: (0, _dateUtil.dateFormat)(endDate, format)
331
+ });
332
+ return;
333
+ }
334
+
335
+ if ((0, _dateUtil.isValid)(startDate) || startDate === '') {
336
+ this.setState({
337
+ texts: [this.callFormatterDate(startDate), ''],
338
+ showPanel: false
339
+ });
340
+ onChange(startDate, startDate ? (0, _dateUtil.dateFormat)(startDate, format) : '');
358
341
  }
359
342
  }
360
343
  }
361
344
  }, {
362
345
  key: "timeCancel",
363
346
  value: function timeCancel() {
364
- var _this$state = this.state,
365
- tempDate = _this$state.tempDate,
366
- format = _this$state.format;
367
- var _this$props7 = this.props,
368
- type = _this$props7.type,
369
- showTime = _this$props7.showTime,
370
- localeDatas = _this$props7.localeDatas,
371
- weekOffset = _this$props7.weekOffset;
347
+ this.setState({
348
+ isFocus: false
349
+ });
350
+ }
351
+ }, {
352
+ key: "inputChangeEvent",
353
+ value: function inputChangeEvent() {
354
+ var _this$state2 = this.state,
355
+ texts = _this$state2.texts,
356
+ date = _this$state2.date,
357
+ format = _this$state2.format;
358
+ var startDate = (0, _dateUtil.parse)(texts[0], format, new Date());
359
+ var endDate = (0, _dateUtil.parse)(texts[1], format, new Date());
360
+
361
+ if (startDate && (0, _dateUtil.isValid)(startDate)) {
362
+ date.startDate ? date.startDate = startDate : date = startDate;
363
+ this.setState({
364
+ date: date
365
+ });
366
+ }
372
367
 
373
- if (tempDate) {
368
+ if (endDate && (0, _dateUtil.isValid)(endDate)) {
369
+ date.endDate && (date.endDate = endDate);
374
370
  this.setState({
375
- date: new Date(tempDate),
376
- text: (0, _constants.formatterDate)(type, new Date(tempDate), format, showTime, localeDatas, weekOffset),
377
- showPanel: false
371
+ date: date
378
372
  });
379
- } else {
373
+ }
374
+
375
+ if (texts[0].trim().length === 0) {
376
+ date.startDate = null;
380
377
  this.setState({
381
- showPanel: false,
382
- isFocus: false
378
+ date: date
379
+ });
380
+ }
381
+
382
+ if (texts[1].trim().length === 0) {
383
+ date.endDate = null;
384
+ this.setState({
385
+ date: date
383
386
  });
384
387
  }
385
388
  }
386
389
  }, {
387
390
  key: "clickOutSide",
388
391
  value: function clickOutSide(e) {
392
+ var _this3 = this;
393
+
394
+ var _this$props5 = this.props,
395
+ max = _this$props5.max,
396
+ min = _this$props5.min;
389
397
  var tar = e.target;
398
+ this.inputChangeEvent();
390
399
 
391
400
  if (tar.className.indexOf('clear') !== -1) {
392
401
  this.setState({
@@ -397,45 +406,59 @@ var BasePicker = /*#__PURE__*/function (_Component) {
397
406
  }
398
407
 
399
408
  if (tar !== this.input && tar !== this.rInput) {
400
- this.timeCancel();
401
- }
409
+ var texts = this.state.texts;
402
410
 
403
- this.callback();
411
+ var _getInRangeDate2 = (0, _util.getInRangeDate)(texts[0], texts[1], max, min),
412
+ startDate = _getInRangeDate2.startDate,
413
+ endDate = _getInRangeDate2.endDate;
414
+
415
+ texts = [this.callFormatterDate(startDate), this.callFormatterDate(endDate)];
416
+ this.setState({
417
+ texts: texts
418
+ }, function () {
419
+ _this3.timeCancel();
420
+
421
+ _this3.callback();
422
+ });
423
+ }
404
424
  }
405
425
  }, {
406
426
  key: "_input",
407
- value: function _input(text) {
408
- var _this5 = this;
409
-
410
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'input';
427
+ value: function _input(text, _ref, placeholder) {
428
+ var _this4 = this;
411
429
 
412
- var placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Please Select...';
413
- var _this$props8 = this.props,
414
- disabled = _this$props8.disabled,
415
- type = _this$props8.type,
416
- _onChange2 = _this$props8.onChange;
417
- return /*#__PURE__*/_react["default"].createElement("input", {
430
+ var _this$props6 = this.props,
431
+ disabled = _this$props6.disabled,
432
+ hourStep = _this$props6.hourStep,
433
+ minuteStep = _this$props6.minuteStep,
434
+ secondStep = _this$props6.secondStep,
435
+ inputReadOnly = _this$props6.inputReadOnly;
436
+ var texts = this.state.texts;
437
+ return _react["default"].createElement("input", {
418
438
  type: "text",
419
439
  ref: function ref(el) {
420
- _this5[_ref] = el;
440
+ _this4[_ref] = el;
421
441
  },
422
442
  placeholder: placeholder,
423
443
  className: disabled ? 'disabled' : '',
424
444
  disabled: disabled,
445
+ readOnly: hourStep || minuteStep || secondStep || inputReadOnly ? 'readOnly' : false,
425
446
  onChange: function onChange(e) {
426
- (0, _constants.isVaildDate)(new Date(e.target.value)) && type === 'date' && _onChange2(new Date(e.target.value));
447
+ _ref === 'input' ? texts[0] = e.target.value : texts[1] = e.target.value;
427
448
 
428
- _this5.setState({
429
- text: e.target.value
449
+ _this4.setState({
450
+ texts: texts
451
+ }, function () {
452
+ _this4.inputChangeEvent();
430
453
  });
431
454
  },
432
455
  onFocus: function onFocus(e) {
433
- _this5.setState({
456
+ _this4.setState({
434
457
  showPanel: true,
435
458
  isFocus: true
436
459
  });
437
460
 
438
- _this5.calcPanelPos(_this5.inputRoot.getBoundingClientRect());
461
+ _this4.calcPanelPos(_this4.inputRoot.current.getBoundingClientRect());
439
462
  },
440
463
  value: text
441
464
  });
@@ -443,15 +466,18 @@ var BasePicker = /*#__PURE__*/function (_Component) {
443
466
  }, {
444
467
  key: "_clear",
445
468
  value: function _clear() {
446
- var onChange = this.props.onChange;
447
-
448
- if (onChange) {
449
- onChange(null);
450
- }
469
+ var _this5 = this;
451
470
 
452
- this.setState({
471
+ var disabled = this.props.disabled;
472
+ !disabled && this.setState({
473
+ date: {
474
+ startDate: null,
475
+ endDate: null
476
+ },
453
477
  texts: ['', ''],
454
478
  isFocus: false
479
+ }, function () {
480
+ _this5.callback();
455
481
  });
456
482
  }
457
483
  }, {
@@ -459,17 +485,24 @@ var BasePicker = /*#__PURE__*/function (_Component) {
459
485
  value: function _icon() {
460
486
  var _this6 = this;
461
487
 
462
- var isFocus = this.state.isFocus;
463
- var iconCls = (0, _classnames["default"])('hi-datepicker__input-icon', 'hi-icon', isFocus ? 'icon-close-circle clear' : 'icon-date');
464
- return isFocus ? /*#__PURE__*/_react["default"].createElement("span", {
488
+ var _this$state3 = this.state,
489
+ isFocus = _this$state3.isFocus,
490
+ texts = _this$state3.texts;
491
+ var _this$props7 = this.props,
492
+ clearable = _this$props7.clearable,
493
+ type = _this$props7.type,
494
+ showTime = _this$props7.showTime,
495
+ disabled = _this$props7.disabled;
496
+ var iconCls = (0, _classnames["default"])('hi-datepicker__input-icon', 'hi-icon', texts[0].length && isFocus && clearable && !disabled ? 'icon-close-circle clear' : type.includes('time') || showTime ? 'icon-time' : 'icon-date');
497
+ return texts[0].length && isFocus && clearable ? _react["default"].createElement("span", {
465
498
  className: iconCls,
466
499
  onClick: this._clear.bind(this)
467
- }) : /*#__PURE__*/_react["default"].createElement("span", {
500
+ }) : _react["default"].createElement("span", {
468
501
  className: iconCls,
469
502
  onClick: function onClick(e) {
470
503
  if (_this6.props.disabled) return;
471
504
 
472
- _this6.calcPanelPos(_this6.inputRoot.getBoundingClientRect());
505
+ _this6.calcPanelPos(_this6.inputRoot.current.getBoundingClientRect());
473
506
 
474
507
  _this6.setState({
475
508
  showPanel: true,
@@ -481,73 +514,117 @@ var BasePicker = /*#__PURE__*/function (_Component) {
481
514
  }, {
482
515
  key: "renderRangeInput",
483
516
  value: function renderRangeInput() {
484
- var _this$props9 = this.props,
485
- localeDatas = _this$props9.localeDatas,
486
- disabled = _this$props9.disabled,
487
- showTime = _this$props9.showTime;
517
+ var _this7 = this;
518
+
519
+ var _this$props8 = this.props,
520
+ localeDatas = _this$props8.localeDatas,
521
+ disabled = _this$props8.disabled,
522
+ showTime = _this$props8.showTime,
523
+ type = _this$props8.type,
524
+ width = _this$props8.width,
525
+ theme = _this$props8.theme;
526
+ var _this$state4 = this.state,
527
+ isFocus = _this$state4.isFocus,
528
+ rangeInputIsError = _this$state4.rangeInputIsError;
488
529
 
489
- var _cls = (0, _classnames["default"])('hi-datepicker__input', 'hi-datepicker__input--range', showTime && 'hi-datepicker__input--range-time', disabled && 'hi-datepicker__input--disabled');
530
+ var _cls = (0, _classnames["default"])('hi-datepicker__input', "theme__".concat(theme), isFocus && 'hi-datepicker__input--focus', "hi-datepicker__input--".concat(type), 'hi-datepicker__input--range', (showTime || type === 'timeperiod') && 'hi-datepicker__input--range-time', disabled && 'hi-datepicker__input--disabled', rangeInputIsError && 'hi-datepicker__input--error');
490
531
 
491
- return /*#__PURE__*/_react["default"].createElement("div", {
492
- className: _cls
493
- }, this._input(this.state.texts[0], 'input', this.state.leftPlaceholder), /*#__PURE__*/_react["default"].createElement("span", null, localeDatas.datePicker.to), this._input(this.state.texts[1], 'rInput', this.state.rightPlaceholder), this._icon());
532
+ return _react["default"].createElement("div", {
533
+ className: _cls,
534
+ style: {
535
+ width: width
536
+ },
537
+ onMouseEnter: function onMouseEnter() {
538
+ _this7.setState({
539
+ isFocus: true
540
+ });
541
+ },
542
+ onMouseLeave: function onMouseLeave() {
543
+ _this7.setState({
544
+ isFocus: false
545
+ });
546
+ }
547
+ }, this._input(this.state.texts[0], 'input', this.state.leftPlaceholder), _react["default"].createElement("span", {
548
+ className: "hi-datepicker__input--connection"
549
+ }, localeDatas.datePicker.to), this._input(this.state.texts[1], 'rInput', this.state.rightPlaceholder), this._icon());
494
550
  }
495
551
  }, {
496
552
  key: "renderNormalInput",
497
553
  value: function renderNormalInput() {
498
- var _this$props10 = this.props,
499
- disabled = _this$props10.disabled,
500
- showTime = _this$props10.showTime;
554
+ var _this8 = this;
555
+
556
+ var _this$props9 = this.props,
557
+ disabled = _this$props9.disabled,
558
+ showTime = _this$props9.showTime,
559
+ type = _this$props9.type,
560
+ width = _this$props9.width,
561
+ theme = _this$props9.theme;
562
+ var isFocus = this.state.isFocus;
501
563
 
502
- var _cls = (0, _classnames["default"])('hi-datepicker__input', 'hi-datepicker__input--normal', disabled && 'hi-datepicker__input--disabled', showTime && 'hi-datepicker__input--middle');
564
+ var _cls = (0, _classnames["default"])('hi-datepicker__input', "theme__".concat(theme), isFocus && 'hi-datepicker__input--focus', "hi-datepicker__input--".concat(type), disabled && 'hi-datepicker__input--disabled', showTime && 'hi-datepicker__input--middle');
503
565
 
504
- return /*#__PURE__*/_react["default"].createElement("div", {
505
- className: _cls
566
+ return _react["default"].createElement("div", {
567
+ className: _cls,
568
+ style: {
569
+ width: width
570
+ },
571
+ onMouseEnter: function onMouseEnter() {
572
+ _this8.setState({
573
+ isFocus: true
574
+ });
575
+ },
576
+ onMouseLeave: function onMouseLeave() {
577
+ _this8.setState({
578
+ isFocus: false
579
+ });
580
+ }
506
581
  }, this._input(this.state.texts[0], 'input', this.state.leftPlaceholder), this._icon());
507
582
  }
508
583
  }, {
509
584
  key: "render",
510
585
  value: function render() {
511
- var _this7 = this;
512
-
513
- var _this$props11 = this.props,
514
- type = _this$props11.type,
515
- showTime = _this$props11.showTime;
516
- return /*#__PURE__*/_react["default"].createElement("span", {
517
- ref: function ref(el) {
518
- _this7.inputRoot = el;
519
- },
520
- className: "hi-datepicker__input-root"
521
- }, type.indexOf('range') !== -1 || type === 'timeperiod' ? this.renderRangeInput() : this.renderNormalInput(), this.state.showPanel ? /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
586
+ var _this$props10 = this.props,
587
+ type = _this$props10.type,
588
+ showTime = _this$props10.showTime,
589
+ width = _this$props10.width;
590
+ return _react["default"].createElement("span", {
591
+ ref: this.inputRoot,
592
+ className: "hi-datepicker__input-root",
593
+ style: {
594
+ width: width
595
+ }
596
+ }, type.indexOf('range') !== -1 || type === 'timeperiod' ? this.renderRangeInput() : this.renderNormalInput(), this.state.showPanel ? _react["default"].createElement(_Modal["default"], {
522
597
  clickOutSide: this.clickOutSide.bind(this),
523
598
  showTime: showTime
524
599
  }, this.initPanel(this.state, this.props)) : null);
525
600
  }
526
601
  }]);
527
-
528
602
  return BasePicker;
529
603
  }(_react.Component);
530
604
 
531
- _defineProperty(BasePicker, "propTypes", {
605
+ BasePicker.propTypes = {
532
606
  type: _propTypes["default"].oneOf(Object.values(_Type["default"])),
533
607
  value: function value(props, propName, componentName) {
534
- // Invalid Date
535
608
  var val = props[propName];
536
609
 
537
610
  if (val === undefined || val === null) {
538
611
  return null;
539
612
  }
540
613
 
614
+ if (!val) {
615
+ return null;
616
+ }
617
+
541
618
  if (val.start && val.end) {
542
- var _start = (0, _dateUtil.dateFormat)(val.start);
619
+ var _start = (0, _dateUtil.isValid)(val.start);
543
620
 
544
- var _end = (0, _dateUtil.dateFormat)(val.end);
621
+ var _end = (0, _dateUtil.isValid)(val.end);
545
622
 
546
- if (_start === 'Invalid Date' || _end === 'Invalid Date') {
623
+ if (!_start || !_end) {
547
624
  return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Validation failed. start or end is an invalid date."));
548
625
  }
549
626
  } else {
550
- if ((0, _dateUtil.dateFormat)(val) === 'Invalid Date') {
627
+ if (!(0, _dateUtil.isValid)(val)) {
551
628
  return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Validation failed. value is an invalid data."));
552
629
  }
553
630
  }
@@ -564,16 +641,17 @@ _defineProperty(BasePicker, "propTypes", {
564
641
  if (val < 5 || val > 480 || val > 60 && val % 60 !== 0 || val < 60 && 60 % val !== 0) {
565
642
  return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". This value must be greater than 5 and less than 480 and is a multiple of 60."));
566
643
  }
567
- }
568
- });
569
-
570
- _defineProperty(BasePicker, "defaultProps", {
644
+ },
645
+ clearable: _propTypes["default"].bool
646
+ };
647
+ BasePicker.defaultProps = {
571
648
  type: 'date',
572
649
  disabled: false,
573
650
  showWeekNumber: true,
574
651
  weekOffset: 0,
575
- timeInterval: 240
576
- });
577
-
652
+ timeInterval: 240,
653
+ clearable: true,
654
+ onSelect: noop
655
+ };
578
656
  var _default = BasePicker;
579
657
  exports["default"] = _default;