amis 1.7.0 → 1.8.0-beta.13

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 (469) hide show
  1. package/lib/Schema.d.ts +10 -2
  2. package/lib/Schema.js +0 -1
  3. package/lib/Schema.js.map +2 -2
  4. package/lib/SchemaRenderer.js +19 -3
  5. package/lib/SchemaRenderer.js.map +2 -2
  6. package/lib/WithRootStore.d.ts +18 -0
  7. package/lib/WithStore.js +2 -1
  8. package/lib/WithStore.js.map +2 -2
  9. package/lib/actions/CmptAction.js +26 -4
  10. package/lib/actions/CmptAction.js.map +2 -2
  11. package/lib/actions/PageAction.d.ts +32 -0
  12. package/lib/actions/PageAction.js +72 -0
  13. package/lib/actions/PageAction.js.map +13 -0
  14. package/lib/actions/index.d.ts +1 -0
  15. package/lib/actions/index.js +1 -0
  16. package/lib/actions/index.js.map +2 -2
  17. package/lib/components/Alert2.js +4 -2
  18. package/lib/components/Alert2.js.map +2 -2
  19. package/lib/components/AssociatedSelection.js +9 -2
  20. package/lib/components/AssociatedSelection.js.map +2 -2
  21. package/lib/components/Avatar.d.ts +20 -20
  22. package/lib/components/BarCode.js +1 -1
  23. package/lib/components/BarCode.js.map +2 -2
  24. package/lib/components/CalendarMobile.d.ts +84 -84
  25. package/lib/components/Card.d.ts +20 -20
  26. package/lib/components/Cascader.d.ts +2 -0
  27. package/lib/components/Cascader.js +28 -12
  28. package/lib/components/Cascader.js.map +2 -2
  29. package/lib/components/Checkbox.d.ts +24 -23
  30. package/lib/components/Checkbox.js +5 -1
  31. package/lib/components/Checkbox.js.map +2 -2
  32. package/lib/components/CityArea.js +3 -0
  33. package/lib/components/CityArea.js.map +2 -2
  34. package/lib/components/Collapse.d.ts +20 -20
  35. package/lib/components/DatePicker.d.ts +87 -84
  36. package/lib/components/DatePicker.js +48 -11
  37. package/lib/components/DatePicker.js.map +2 -2
  38. package/lib/components/DateRangePicker.d.ts +285 -171
  39. package/lib/components/DateRangePicker.js +471 -66
  40. package/lib/components/DateRangePicker.js.map +2 -2
  41. package/lib/components/Drawer.js +1 -1
  42. package/lib/components/Drawer.js.map +2 -2
  43. package/lib/components/ListGroup.d.ts +21 -21
  44. package/lib/components/Modal.js +1 -1
  45. package/lib/components/Modal.js.map +2 -2
  46. package/lib/components/MonthRangePicker.d.ts +84 -84
  47. package/lib/components/Overlay.d.ts +1 -0
  48. package/lib/components/Overlay.js +4 -3
  49. package/lib/components/Overlay.js.map +2 -2
  50. package/lib/components/Progress.d.ts +29 -24
  51. package/lib/components/Progress.js +52 -21
  52. package/lib/components/Progress.js.map +2 -2
  53. package/lib/components/PullRefresh.d.ts +86 -0
  54. package/lib/components/PullRefresh.js +135 -0
  55. package/lib/components/PullRefresh.js.map +13 -0
  56. package/lib/components/Radios.d.ts +22 -22
  57. package/lib/components/Radios.js +3 -5
  58. package/lib/components/Radios.js.map +2 -2
  59. package/lib/components/Range.d.ts +2 -2
  60. package/lib/components/Range.js +24 -11
  61. package/lib/components/Range.js.map +2 -2
  62. package/lib/components/Spinner.d.ts +200 -107
  63. package/lib/components/Spinner.js +30 -26
  64. package/lib/components/Spinner.js.map +2 -2
  65. package/lib/components/Steps.d.ts +6 -0
  66. package/lib/components/Steps.js +13 -9
  67. package/lib/components/Steps.js.map +2 -2
  68. package/lib/components/Tabs.d.ts +27 -23
  69. package/lib/components/Tabs.js +37 -22
  70. package/lib/components/Tabs.js.map +2 -2
  71. package/lib/components/Tooltip.d.ts +4 -0
  72. package/lib/components/Tooltip.js +6 -4
  73. package/lib/components/Tooltip.js.map +2 -2
  74. package/lib/components/TooltipWrapper.d.ts +87 -24
  75. package/lib/components/TooltipWrapper.js +40 -8
  76. package/lib/components/TooltipWrapper.js.map +2 -2
  77. package/lib/components/Transfer.d.ts +84 -84
  78. package/lib/components/TransferDropDown.d.ts +84 -84
  79. package/lib/components/Tree.d.ts +87 -85
  80. package/lib/components/Tree.js +13 -5
  81. package/lib/components/Tree.js.map +2 -2
  82. package/lib/components/TreeSelection.d.ts +84 -84
  83. package/lib/components/calendar/Calendar.js +3 -12
  84. package/lib/components/calendar/Calendar.js.map +2 -2
  85. package/lib/components/calendar/TimeView.d.ts +1 -0
  86. package/lib/components/calendar/TimeView.js +7 -0
  87. package/lib/components/calendar/TimeView.js.map +2 -2
  88. package/lib/components/calendar/YearsView.js +3 -3
  89. package/lib/components/calendar/YearsView.js.map +2 -2
  90. package/lib/components/condition-builder/Expression.d.ts +1 -0
  91. package/lib/components/condition-builder/Expression.js +4 -4
  92. package/lib/components/condition-builder/Expression.js.map +2 -2
  93. package/lib/components/condition-builder/Field.d.ts +1 -0
  94. package/lib/components/condition-builder/Field.js +3 -2
  95. package/lib/components/condition-builder/Field.js.map +2 -2
  96. package/lib/components/condition-builder/Group.d.ts +1 -0
  97. package/lib/components/condition-builder/Group.js +2 -2
  98. package/lib/components/condition-builder/Group.js.map +2 -2
  99. package/lib/components/condition-builder/GroupOrItem.d.ts +1 -0
  100. package/lib/components/condition-builder/GroupOrItem.js +2 -2
  101. package/lib/components/condition-builder/GroupOrItem.js.map +2 -2
  102. package/lib/components/condition-builder/InputSwitch.d.ts +2 -1
  103. package/lib/components/condition-builder/InputSwitch.js +2 -2
  104. package/lib/components/condition-builder/InputSwitch.js.map +2 -2
  105. package/lib/components/condition-builder/Item.d.ts +1 -0
  106. package/lib/components/condition-builder/Item.js +9 -8
  107. package/lib/components/condition-builder/Item.js.map +2 -2
  108. package/lib/components/condition-builder/Value.d.ts +1 -0
  109. package/lib/components/condition-builder/Value.js +5 -5
  110. package/lib/components/condition-builder/Value.js.map +2 -2
  111. package/lib/components/condition-builder/index.d.ts +1 -0
  112. package/lib/components/condition-builder/index.js +2 -2
  113. package/lib/components/condition-builder/index.js.map +2 -2
  114. package/lib/components/formula/Editor.d.ts +90 -86
  115. package/lib/components/formula/Editor.js +26 -4
  116. package/lib/components/formula/Editor.js.map +2 -2
  117. package/lib/components/formula/Picker.d.ts +5 -0
  118. package/lib/components/formula/Picker.js +21 -4
  119. package/lib/components/formula/Picker.js.map +2 -2
  120. package/lib/components/icons.js +2 -0
  121. package/lib/components/icons.js.map +2 -2
  122. package/lib/factory.d.ts +5 -0
  123. package/lib/factory.js +24 -3
  124. package/lib/factory.js.map +2 -2
  125. package/lib/icons/trash.js +10 -0
  126. package/lib/index.d.ts +1 -0
  127. package/lib/index.js +2 -1
  128. package/lib/index.js.map +2 -2
  129. package/lib/locale/de-DE.js +18 -1
  130. package/lib/locale/de-DE.js.map +2 -2
  131. package/lib/locale/en-US.js +18 -1
  132. package/lib/locale/en-US.js.map +2 -2
  133. package/lib/locale/zh-CN.js +18 -1
  134. package/lib/locale/zh-CN.js.map +2 -2
  135. package/lib/renderers/Action.d.ts +3 -1
  136. package/lib/renderers/Action.js +23 -5
  137. package/lib/renderers/Action.js.map +2 -2
  138. package/lib/renderers/App.d.ts +1 -0
  139. package/lib/renderers/App.js +3 -0
  140. package/lib/renderers/App.js.map +2 -2
  141. package/lib/renderers/ButtonGroup.d.ts +2 -2
  142. package/lib/renderers/ButtonGroup.js.map +1 -1
  143. package/lib/renderers/CRUD.d.ts +8 -0
  144. package/lib/renderers/CRUD.js +12 -5
  145. package/lib/renderers/CRUD.js.map +2 -2
  146. package/lib/renderers/Carousel.d.ts +1 -0
  147. package/lib/renderers/Carousel.js +13 -1
  148. package/lib/renderers/Carousel.js.map +2 -2
  149. package/lib/renderers/Chart.d.ts +1 -0
  150. package/lib/renderers/Chart.js +3 -0
  151. package/lib/renderers/Chart.js.map +2 -2
  152. package/lib/renderers/Dialog.d.ts +5 -0
  153. package/lib/renderers/Dialog.js +7 -3
  154. package/lib/renderers/Dialog.js.map +2 -2
  155. package/lib/renderers/Drawer.d.ts +1 -0
  156. package/lib/renderers/Drawer.js +6 -1
  157. package/lib/renderers/Drawer.js.map +2 -2
  158. package/lib/renderers/DropDownButton.d.ts +2 -0
  159. package/lib/renderers/DropDownButton.js +13 -4
  160. package/lib/renderers/DropDownButton.js.map +2 -2
  161. package/lib/renderers/Form/Checkbox.d.ts +5 -2
  162. package/lib/renderers/Form/Checkbox.js +2 -2
  163. package/lib/renderers/Form/Checkbox.js.map +2 -2
  164. package/lib/renderers/Form/Checkboxes.d.ts +7 -2
  165. package/lib/renderers/Form/Checkboxes.js +101 -12
  166. package/lib/renderers/Form/Checkboxes.js.map +2 -2
  167. package/lib/renderers/Form/Combo.d.ts +6 -4
  168. package/lib/renderers/Form/Combo.js +132 -45
  169. package/lib/renderers/Form/Combo.js.map +2 -2
  170. package/lib/renderers/Form/DiffEditor.d.ts +3 -2
  171. package/lib/renderers/Form/Editor.d.ts +2 -2
  172. package/lib/renderers/Form/InputCity.d.ts +87 -84
  173. package/lib/renderers/Form/InputCity.js +48 -3
  174. package/lib/renderers/Form/InputCity.js.map +2 -2
  175. package/lib/renderers/Form/InputDate.js +10 -3
  176. package/lib/renderers/Form/InputDate.js.map +2 -2
  177. package/lib/renderers/Form/InputDateRange.d.ts +5 -0
  178. package/lib/renderers/Form/InputDateRange.js +12 -3
  179. package/lib/renderers/Form/InputDateRange.js.map +2 -2
  180. package/lib/renderers/Form/InputFile.js +19 -8
  181. package/lib/renderers/Form/InputFile.js.map +2 -2
  182. package/lib/renderers/Form/InputFormula.d.ts +4 -0
  183. package/lib/renderers/Form/InputFormula.js +2 -2
  184. package/lib/renderers/Form/InputFormula.js.map +2 -2
  185. package/lib/renderers/Form/InputImage.js +18 -7
  186. package/lib/renderers/Form/InputImage.js.map +2 -2
  187. package/lib/renderers/Form/InputMonthRange.js +5 -1
  188. package/lib/renderers/Form/InputMonthRange.js.map +2 -2
  189. package/lib/renderers/Form/InputRange.d.ts +2 -2
  190. package/lib/renderers/Form/InputRange.js +13 -14
  191. package/lib/renderers/Form/InputRange.js.map +2 -2
  192. package/lib/renderers/Form/InputTable.js +4 -2
  193. package/lib/renderers/Form/InputTable.js.map +2 -2
  194. package/lib/renderers/Form/InputText.d.ts +1 -1
  195. package/lib/renderers/Form/InputText.js +8 -10
  196. package/lib/renderers/Form/InputText.js.map +2 -2
  197. package/lib/renderers/Form/InputTree.d.ts +5 -0
  198. package/lib/renderers/Form/InputTree.js +51 -2
  199. package/lib/renderers/Form/InputTree.js.map +2 -2
  200. package/lib/renderers/Form/Item.d.ts +79 -76
  201. package/lib/renderers/Form/Item.js +3 -1
  202. package/lib/renderers/Form/Item.js.map +2 -2
  203. package/lib/renderers/Form/NestedSelect.d.ts +4 -0
  204. package/lib/renderers/Form/NestedSelect.js +14 -5
  205. package/lib/renderers/Form/NestedSelect.js.map +2 -2
  206. package/lib/renderers/Form/Options.js +61 -27
  207. package/lib/renderers/Form/Options.js.map +2 -2
  208. package/lib/renderers/Form/Select.js +4 -2
  209. package/lib/renderers/Form/Select.js.map +2 -2
  210. package/lib/renderers/Form/Textarea.js +2 -1
  211. package/lib/renderers/Form/Textarea.js.map +2 -2
  212. package/lib/renderers/Form/TreeSelect.d.ts +11 -2
  213. package/lib/renderers/Form/TreeSelect.js +56 -10
  214. package/lib/renderers/Form/TreeSelect.js.map +2 -2
  215. package/lib/renderers/Form/index.d.ts +3 -0
  216. package/lib/renderers/Form/index.js +53 -16
  217. package/lib/renderers/Form/index.js.map +2 -2
  218. package/lib/renderers/Form/wrapControl.d.ts +10 -0
  219. package/lib/renderers/Form/wrapControl.js +41 -19
  220. package/lib/renderers/Form/wrapControl.js.map +2 -2
  221. package/lib/renderers/Nav.d.ts +82 -67
  222. package/lib/renderers/Nav.js +49 -13
  223. package/lib/renderers/Nav.js.map +2 -2
  224. package/lib/renderers/Page.d.ts +21 -0
  225. package/lib/renderers/Page.js +56 -17
  226. package/lib/renderers/Page.js.map +2 -2
  227. package/lib/renderers/Progress.d.ts +4 -7
  228. package/lib/renderers/Progress.js +3 -3
  229. package/lib/renderers/Progress.js.map +2 -2
  230. package/lib/renderers/Service.d.ts +3 -0
  231. package/lib/renderers/Service.js +55 -20
  232. package/lib/renderers/Service.js.map +2 -2
  233. package/lib/renderers/Spinner.d.ts +58 -2
  234. package/lib/renderers/Spinner.js +8 -1
  235. package/lib/renderers/Spinner.js.map +2 -2
  236. package/lib/renderers/Steps.d.ts +8 -0
  237. package/lib/renderers/Steps.js +2 -2
  238. package/lib/renderers/Steps.js.map +2 -2
  239. package/lib/renderers/Table/ColumnToggler.d.ts +4 -0
  240. package/lib/renderers/Table/ColumnToggler.js +11 -6
  241. package/lib/renderers/Table/ColumnToggler.js.map +2 -2
  242. package/lib/renderers/Table/TableCell.js +27 -1
  243. package/lib/renderers/Table/TableCell.js.map +2 -2
  244. package/lib/renderers/Table/TableRow.js +1 -1
  245. package/lib/renderers/Table/TableRow.js.map +2 -2
  246. package/lib/renderers/Table/index.d.ts +2 -0
  247. package/lib/renderers/Table/index.js +23 -10
  248. package/lib/renderers/Table/index.js.map +2 -2
  249. package/lib/renderers/Tabs.d.ts +14 -2
  250. package/lib/renderers/Tabs.js +24 -8
  251. package/lib/renderers/Tabs.js.map +2 -2
  252. package/lib/renderers/TooltipWrapper.d.ts +133 -0
  253. package/lib/renderers/TooltipWrapper.js +70 -0
  254. package/lib/renderers/TooltipWrapper.js.map +13 -0
  255. package/lib/renderers/Wizard.d.ts +7 -3
  256. package/lib/renderers/Wizard.js +269 -152
  257. package/lib/renderers/Wizard.js.map +2 -2
  258. package/lib/store/combo.d.ts +2 -2
  259. package/lib/store/crud.d.ts +1 -0
  260. package/lib/store/crud.js +55 -19
  261. package/lib/store/crud.js.map +2 -2
  262. package/lib/store/form.d.ts +1 -1
  263. package/lib/store/form.js +5 -1
  264. package/lib/store/form.js.map +2 -2
  265. package/lib/store/formItem.js +1 -1
  266. package/lib/store/formItem.js.map +2 -2
  267. package/lib/store/index.d.ts +5 -0
  268. package/lib/store/index.js +14 -0
  269. package/lib/store/index.js.map +2 -2
  270. package/lib/store/table.d.ts +2 -2
  271. package/lib/store/table.js +4 -4
  272. package/lib/store/table.js.map +2 -2
  273. package/lib/themes/ang-ie11.css +965 -210
  274. package/lib/themes/ang.css +955 -175
  275. package/lib/themes/ang.css.map +1 -1
  276. package/lib/themes/antd-ie11.css +1080 -325
  277. package/lib/themes/antd.css +956 -176
  278. package/lib/themes/antd.css.map +1 -1
  279. package/lib/themes/cxd-ie11.css +1048 -293
  280. package/lib/themes/cxd.css +961 -180
  281. package/lib/themes/cxd.css.map +1 -1
  282. package/lib/themes/dark-ie11.css +965 -210
  283. package/lib/themes/dark.css +955 -175
  284. package/lib/themes/dark.css.map +1 -1
  285. package/lib/themes/default-ie11.css +1048 -293
  286. package/lib/themes/default.css +961 -180
  287. package/lib/themes/default.css.map +1 -1
  288. package/lib/types.d.ts +3 -1
  289. package/lib/types.js.map +1 -1
  290. package/lib/utils/ColorScale.d.ts +19 -0
  291. package/lib/utils/ColorScale.js +104 -0
  292. package/lib/utils/ColorScale.js.map +13 -0
  293. package/lib/utils/api.js +20 -4
  294. package/lib/utils/api.js.map +2 -2
  295. package/lib/utils/columnsSplit.d.ts +1 -0
  296. package/lib/utils/columnsSplit.js +40 -0
  297. package/lib/utils/columnsSplit.js.map +13 -0
  298. package/lib/utils/debug.d.ts +1 -1
  299. package/lib/utils/debug.js +16 -22
  300. package/lib/utils/debug.js.map +2 -2
  301. package/lib/utils/dom.d.ts +1 -1
  302. package/lib/utils/dom.js +7 -5
  303. package/lib/utils/dom.js.map +2 -2
  304. package/lib/utils/position.js +0 -1
  305. package/lib/utils/position.js.map +2 -2
  306. package/lib/utils/scrollPosition.d.ts +6 -0
  307. package/lib/utils/scrollPosition.js +31 -0
  308. package/lib/utils/scrollPosition.js.map +13 -0
  309. package/package.json +3 -2
  310. package/schema.json +30213 -29222
  311. package/scss/_properties.scss +67 -25
  312. package/scss/components/_alert.scss +1 -1
  313. package/scss/components/_barcode.scss +1 -1
  314. package/scss/components/_button-group.scss +15 -0
  315. package/scss/components/_carousel.scss +1 -0
  316. package/scss/components/_column-toggler.scss +21 -11
  317. package/scss/components/_debug.scss +3 -3
  318. package/scss/components/_formula.scss +19 -1
  319. package/scss/components/_nav.scss +51 -6
  320. package/scss/components/_progress.scss +7 -14
  321. package/scss/components/_pull-refresh.scss +25 -0
  322. package/scss/components/_spinner.scss +134 -56
  323. package/scss/components/_steps.scss +199 -8
  324. package/scss/components/_tabs.scss +145 -13
  325. package/scss/components/_tooltip.scss +76 -9
  326. package/scss/components/form/_checks.scss +125 -2
  327. package/scss/components/form/_combo.scss +13 -1
  328. package/scss/components/form/_date-range.scss +27 -2
  329. package/scss/components/form/_date.scss +25 -0
  330. package/scss/components/form/_editor.scss +2 -1
  331. package/scss/components/form/_file.scss +4 -0
  332. package/scss/components/form/_form.scss +31 -8
  333. package/scss/components/form/_number.scss +5 -2
  334. package/scss/components/form/_select.scss +0 -1
  335. package/scss/components/form/_textarea.scss +1 -23
  336. package/scss/components/form/_transfer.scss +3 -2
  337. package/scss/themes/_antd-variables.scss +1 -1
  338. package/scss/themes/_common.scss +1 -0
  339. package/scss/themes/_cxd-variables.scss +6 -5
  340. package/sdk/ang-ie11.css +1059 -198
  341. package/sdk/ang.css +1050 -164
  342. package/sdk/antd-ie11.css +1167 -306
  343. package/sdk/antd.css +1051 -165
  344. package/sdk/barcode.js +51 -51
  345. package/sdk/charts.js +14 -14
  346. package/sdk/codemirror.js +7 -7
  347. package/sdk/color-picker.js +65 -65
  348. package/sdk/cropperjs.js +2 -2
  349. package/sdk/cxd-ie11.css +1145 -284
  350. package/sdk/cxd.css +1056 -169
  351. package/sdk/dark-ie11.css +1056 -195
  352. package/sdk/dark.css +1050 -164
  353. package/sdk/exceljs.js +1 -1
  354. package/sdk/locale/de-DE.js +18 -1
  355. package/sdk/markdown.js +69 -69
  356. package/sdk/papaparse.js +1 -1
  357. package/sdk/renderers/Form/CityDB.js +1 -1
  358. package/sdk/rest.js +17 -17
  359. package/sdk/rich-text.js +62 -62
  360. package/sdk/sdk-ie11.css +1145 -284
  361. package/sdk/sdk.css +1056 -169
  362. package/sdk/sdk.js +1321 -1273
  363. package/sdk/thirds/hls.js/hls.js +1 -1
  364. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  365. package/sdk/tinymce.js +57 -57
  366. package/src/Schema.ts +15 -2
  367. package/src/SchemaRenderer.tsx +32 -14
  368. package/src/WithStore.tsx +3 -1
  369. package/src/actions/CmptAction.ts +28 -0
  370. package/src/actions/PageAction.ts +62 -0
  371. package/src/actions/index.ts +1 -0
  372. package/src/components/Alert2.tsx +9 -3
  373. package/src/components/AssociatedSelection.tsx +9 -3
  374. package/src/components/BarCode.tsx +2 -2
  375. package/src/components/Cascader.tsx +37 -11
  376. package/src/components/Checkbox.tsx +11 -5
  377. package/src/components/CityArea.tsx +3 -0
  378. package/src/components/DatePicker.tsx +68 -22
  379. package/src/components/DateRangePicker.tsx +551 -88
  380. package/src/components/Drawer.tsx +1 -0
  381. package/src/components/Modal.tsx +1 -0
  382. package/src/components/Overlay.tsx +6 -3
  383. package/src/components/Progress.tsx +64 -33
  384. package/src/components/PullRefresh.tsx +197 -0
  385. package/src/components/Radios.tsx +6 -17
  386. package/src/components/Range.tsx +26 -12
  387. package/src/components/Spinner.tsx +77 -42
  388. package/src/components/Steps.tsx +28 -27
  389. package/src/components/Tabs.tsx +51 -21
  390. package/src/components/Tooltip.tsx +12 -3
  391. package/src/components/TooltipWrapper.tsx +140 -33
  392. package/src/components/Tree.tsx +19 -5
  393. package/src/components/calendar/Calendar.tsx +4 -13
  394. package/src/components/calendar/TimeView.tsx +12 -0
  395. package/src/components/calendar/YearsView.tsx +3 -4
  396. package/src/components/condition-builder/Expression.tsx +6 -1
  397. package/src/components/condition-builder/Field.tsx +5 -1
  398. package/src/components/condition-builder/Group.tsx +4 -1
  399. package/src/components/condition-builder/GroupOrItem.tsx +4 -1
  400. package/src/components/condition-builder/InputSwitch.tsx +4 -1
  401. package/src/components/condition-builder/Item.tsx +28 -4
  402. package/src/components/condition-builder/Value.tsx +7 -1
  403. package/src/components/condition-builder/index.tsx +4 -2
  404. package/src/components/formula/Editor.tsx +46 -10
  405. package/src/components/formula/Picker.tsx +32 -1
  406. package/src/components/icons.tsx +2 -0
  407. package/src/factory.tsx +31 -3
  408. package/src/icons/trash.svg +8 -0
  409. package/src/index.tsx +1 -0
  410. package/src/locale/de-DE.ts +18 -1
  411. package/src/locale/en-US.ts +18 -1
  412. package/src/locale/zh-CN.ts +18 -1
  413. package/src/renderers/Action.tsx +24 -2
  414. package/src/renderers/App.tsx +4 -0
  415. package/src/renderers/ButtonGroup.tsx +2 -2
  416. package/src/renderers/CRUD.tsx +23 -5
  417. package/src/renderers/Carousel.tsx +8 -0
  418. package/src/renderers/Chart.tsx +4 -0
  419. package/src/renderers/Dialog.tsx +21 -3
  420. package/src/renderers/Drawer.tsx +14 -2
  421. package/src/renderers/DropDownButton.tsx +14 -3
  422. package/src/renderers/Form/Checkbox.tsx +11 -2
  423. package/src/renderers/Form/Checkboxes.tsx +106 -23
  424. package/src/renderers/Form/Combo.tsx +179 -66
  425. package/src/renderers/Form/InputCity.tsx +46 -5
  426. package/src/renderers/Form/InputDate.tsx +18 -4
  427. package/src/renderers/Form/InputDateRange.tsx +27 -3
  428. package/src/renderers/Form/InputFile.tsx +23 -7
  429. package/src/renderers/Form/InputFormula.tsx +7 -0
  430. package/src/renderers/Form/InputImage.tsx +22 -6
  431. package/src/renderers/Form/InputMonthRange.tsx +7 -1
  432. package/src/renderers/Form/InputRange.tsx +20 -22
  433. package/src/renderers/Form/InputTable.tsx +6 -2
  434. package/src/renderers/Form/InputText.tsx +14 -4
  435. package/src/renderers/Form/InputTree.tsx +40 -2
  436. package/src/renderers/Form/Item.tsx +7 -0
  437. package/src/renderers/Form/NestedSelect.tsx +23 -4
  438. package/src/renderers/Form/Options.tsx +26 -7
  439. package/src/renderers/Form/Select.tsx +5 -3
  440. package/src/renderers/Form/Textarea.tsx +3 -1
  441. package/src/renderers/Form/TreeSelect.tsx +47 -9
  442. package/src/renderers/Form/index.tsx +56 -25
  443. package/src/renderers/Form/wrapControl.tsx +23 -12
  444. package/src/renderers/Nav.tsx +231 -33
  445. package/src/renderers/Page.tsx +97 -35
  446. package/src/renderers/Progress.tsx +9 -11
  447. package/src/renderers/Service.tsx +66 -27
  448. package/src/renderers/Spinner.tsx +85 -3
  449. package/src/renderers/Steps.tsx +14 -0
  450. package/src/renderers/Table/ColumnToggler.tsx +36 -11
  451. package/src/renderers/Table/TableCell.tsx +39 -1
  452. package/src/renderers/Table/TableRow.tsx +1 -1
  453. package/src/renderers/Table/index.tsx +43 -19
  454. package/src/renderers/Tabs.tsx +90 -31
  455. package/src/renderers/TooltipWrapper.tsx +262 -0
  456. package/src/renderers/Wizard.tsx +169 -93
  457. package/src/store/crud.ts +50 -5
  458. package/src/store/form.ts +8 -3
  459. package/src/store/formItem.ts +1 -2
  460. package/src/store/index.ts +20 -0
  461. package/src/store/table.ts +4 -4
  462. package/src/types.ts +8 -1
  463. package/src/utils/ColorScale.ts +138 -0
  464. package/src/utils/api.ts +26 -4
  465. package/src/utils/columnsSplit.tsx +57 -0
  466. package/src/utils/debug.tsx +17 -24
  467. package/src/utils/dom.tsx +7 -6
  468. package/src/utils/position.ts +0 -1
  469. package/src/utils/scrollPosition.ts +29 -0
@@ -7,7 +7,6 @@
7
7
  import React from 'react';
8
8
  import moment from 'moment';
9
9
  import {findDOMNode} from 'react-dom';
10
- import cx from 'classnames';
11
10
  import {Icon} from './icons';
12
11
  import Overlay from './Overlay';
13
12
  import {ShortCuts, ShortCutDateRange} from './DatePicker';
@@ -19,11 +18,13 @@ import {PlainObject} from '../types';
19
18
  import {isMobile, noop, ucFirst} from '../utils/helper';
20
19
  import {LocaleProps, localeable} from '../locale';
21
20
  import CalendarMobile from './CalendarMobile';
21
+ import Input from './Input';
22
22
 
23
23
  export interface DateRangePickerProps extends ThemeProps, LocaleProps {
24
24
  className?: string;
25
25
  popoverClassName?: string;
26
- placeholder?: string;
26
+ startPlaceholder?: string;
27
+ endPlaceholder?: string;
27
28
  theme?: any;
28
29
  format: string;
29
30
  utc?: boolean;
@@ -52,6 +53,7 @@ export interface DateRangePickerProps extends ThemeProps, LocaleProps {
52
53
  useMobileUI?: boolean;
53
54
  onFocus?: Function;
54
55
  onBlur?: Function;
56
+ type?: string;
55
57
  }
56
58
 
57
59
  export interface DateRangePickerState {
@@ -59,6 +61,9 @@ export interface DateRangePickerState {
59
61
  isFocused: boolean;
60
62
  startDate?: moment.Moment;
61
63
  endDate?: moment.Moment;
64
+ editState?: 'start' | 'end'; // 编辑开始时间还是结束时间
65
+ startInputValue?: string;
66
+ endInputValue?: string;
62
67
  }
63
68
 
64
69
  export const availableRanges: {[propName: string]: any} = {
@@ -82,8 +87,19 @@ export const availableRanges: {[propName: string]: any} = {
82
87
  }
83
88
  },
84
89
 
85
- '1dayago': {
86
- label: 'DateRange.1dayago',
90
+ 'tomorrow': {
91
+ label: 'Date.tomorrow',
92
+ startDate: (now: moment.Moment) => {
93
+ return now.add(1, 'days').startOf('day');
94
+ },
95
+ endDate: (now: moment.Moment) => {
96
+ return now.add(1, 'days').endOf('day');
97
+ }
98
+ },
99
+
100
+ // 兼容一下错误的用法
101
+ '1daysago': {
102
+ label: 'DateRange.1daysago',
87
103
  startDate: (now: moment.Moment) => {
88
104
  return now.add(-1, 'days');
89
105
  },
@@ -203,12 +219,184 @@ export const availableRanges: {[propName: string]: any} = {
203
219
  }
204
220
  };
205
221
 
222
+ export const advancedRanges = [
223
+ {
224
+ regexp: /^(\d+)hoursago$/,
225
+ resolve: (__: any, _: string, hours: string) => {
226
+ return {
227
+ label: __('DateRange.hoursago', {hours}),
228
+ startDate: (now: moment.Moment) => {
229
+ return now.add(-hours, 'hours').startOf('hour');
230
+ },
231
+ endDate: (now: moment.Moment) => {
232
+ return now.add(-1, 'hours').endOf('hours');
233
+ }
234
+ };
235
+ }
236
+ },
237
+ {
238
+ regexp: /^(\d+)hourslater$/,
239
+ resolve: (__: any, _: string, hours: string) => {
240
+ return {
241
+ label: __('DateRange.hourslater', {hours}),
242
+ startDate: (now: moment.Moment) => {
243
+ return now.startOf('hour');
244
+ },
245
+ endDate: (now: moment.Moment) => {
246
+ return now.add(hours, 'hours').endOf('hour');
247
+ }
248
+ };
249
+ }
250
+ },
251
+ {
252
+ regexp: /^(\d+)daysago$/,
253
+ resolve: (__: any, _: string, days: string) => {
254
+ return {
255
+ label: __('DateRange.daysago', {days}),
256
+ startDate: (now: moment.Moment) => {
257
+ return now.add(-days, 'days').startOf('day');
258
+ },
259
+ endDate: (now: moment.Moment) => {
260
+ return now.add(-1, 'days').endOf('day');
261
+ }
262
+ };
263
+ }
264
+ },
265
+ {
266
+ regexp: /^(\d+)dayslater$/,
267
+ resolve: (__: any, _: string, days: string) => {
268
+ return {
269
+ label: __('DateRange.dayslater', {days}),
270
+ startDate: (now: moment.Moment) => {
271
+ return now.startOf('day');
272
+ },
273
+ endDate: (now: moment.Moment) => {
274
+ return now.add(days, 'days').endOf('day');
275
+ }
276
+ };
277
+ }
278
+ },
279
+ {
280
+ regexp: /^(\d+)weeksago$/,
281
+ resolve: (__: any, _: string, weeks: string) => {
282
+ return {
283
+ label: __('DateRange.weeksago', {weeks}),
284
+ startDate: (now: moment.Moment) => {
285
+ return now.startOf('week').add(-weeks, 'weeks');
286
+ },
287
+ endDate: (now: moment.Moment) => {
288
+ return now.startOf('week').add(-1, 'days').endOf('day');
289
+ }
290
+ };
291
+ }
292
+ },
293
+ {
294
+ regexp: /^(\d+)weekslater$/,
295
+ resolve: (__: any, _: string, weeks: string) => {
296
+ return {
297
+ label: __('DateRange.weekslater', {weeks}),
298
+ startDate: (now: moment.Moment) => {
299
+ return now.startOf('week');
300
+ },
301
+ endDate: (now: moment.Moment) => {
302
+ return now.startOf('week').add(weeks, 'weeks').endOf('day');
303
+ }
304
+ };
305
+ }
306
+ },
307
+ {
308
+ regexp: /^(\d+)monthsago$/,
309
+ resolve: (__: any, _: string, months: string) => {
310
+ return {
311
+ label: __('DateRange.monthsago', {months}),
312
+ startDate: (now: moment.Moment) => {
313
+ return now.startOf('months').add(-months, 'months');
314
+ },
315
+ endDate: (now: moment.Moment) => {
316
+ return now.startOf('month').add(-1, 'days').endOf('day');
317
+ }
318
+ };
319
+ }
320
+ },
321
+ {
322
+ regexp: /^(\d+)monthslater$/,
323
+ resolve: (__: any, _: string, months: string) => {
324
+ return {
325
+ label: __('DateRange.monthslater', {months}),
326
+ startDate: (now: moment.Moment) => {
327
+ return now.startOf('month');
328
+ },
329
+ endDate: (now: moment.Moment) => {
330
+ return now.startOf('month').add(months, 'months').endOf('day');
331
+ }
332
+ };
333
+ }
334
+ },
335
+ {
336
+ regexp: /^(\d+)quartersago$/,
337
+ resolve: (__: any, _: string, quarters: string) => {
338
+ return {
339
+ label: __('DateRange.quartersago', {quarters}),
340
+ startDate: (now: moment.Moment) => {
341
+ return now.startOf('quarters').add(-quarters, 'quarters');
342
+ },
343
+ endDate: (now: moment.Moment) => {
344
+ return now.startOf('quarter').add(-1, 'days').endOf('day');
345
+ }
346
+ };
347
+ }
348
+ },
349
+ {
350
+ regexp: /^(\d+)quarterslater$/,
351
+ resolve: (__: any, _: string, quarters: string) => {
352
+ return {
353
+ label: __('DateRange.quarterslater', {quarters}),
354
+ startDate: (now: moment.Moment) => {
355
+ return now.startOf('quarter');
356
+ },
357
+ endDate: (now: moment.Moment) => {
358
+ return now.startOf('quarter').add(quarters, 'quarters').endOf('day');
359
+ }
360
+ };
361
+ }
362
+ },
363
+ {
364
+ regexp: /^(\d+)yearsago$/,
365
+ resolve: (__: any, _: string, years: string) => {
366
+ return {
367
+ label: __('DateRange.yearsago', {years}),
368
+ startDate: (now: moment.Moment) => {
369
+ return now.startOf('years').add(-years, 'years');
370
+ },
371
+ endDate: (now: moment.Moment) => {
372
+ return now.startOf('year').add(-1, 'days').endOf('day');
373
+ }
374
+ };
375
+ }
376
+ },
377
+ {
378
+ regexp: /^(\d+)yearslater$/,
379
+ resolve: (__: any, _: string, years: string) => {
380
+ return {
381
+ label: __('DateRange.yearslater', {years}),
382
+ startDate: (now: moment.Moment) => {
383
+ return now.startOf('year');
384
+ },
385
+ endDate: (now: moment.Moment) => {
386
+ return now.startOf('year').add(years, 'years').endOf('day');
387
+ }
388
+ };
389
+ }
390
+ }
391
+ ];
392
+
206
393
  export class DateRangePicker extends React.Component<
207
394
  DateRangePickerProps,
208
395
  DateRangePickerState
209
396
  > {
210
397
  static defaultProps = {
211
- placeholder: 'DateRange.placeholder',
398
+ startPlaceholder: 'Calendar.startPick',
399
+ endPlaceholder: 'Calendar.endPick',
212
400
  format: 'X',
213
401
  inputFormat: 'YYYY-MM-DD',
214
402
  joinValues: true,
@@ -272,14 +460,29 @@ export class DateRangePicker extends React.Component<
272
460
  }
273
461
 
274
462
  dom: React.RefObject<HTMLDivElement>;
463
+ calendarRef: React.RefObject<HTMLDivElement>;
275
464
  nextMonth = moment().add(1, 'months');
276
465
 
466
+ startInputRef: React.RefObject<HTMLInputElement>;
467
+ endInputRef: React.RefObject<HTMLInputElement>;
468
+
277
469
  constructor(props: DateRangePickerProps) {
278
470
  super(props);
279
471
 
472
+ this.startInputRef = React.createRef();
473
+ this.endInputRef = React.createRef();
474
+ this.calendarRef = React.createRef();
280
475
  this.open = this.open.bind(this);
476
+ this.openStart = this.openStart.bind(this);
477
+ this.openEnd = this.openEnd.bind(this);
281
478
  this.close = this.close.bind(this);
282
- this.handleSelectChange = this.handleSelectChange.bind(this);
479
+ this.startInputChange = this.startInputChange.bind(this);
480
+ this.endInputChange = this.endInputChange.bind(this);
481
+ this.handleDateChange = this.handleDateChange.bind(this);
482
+ this.handleStartDateChange = this.handleStartDateChange.bind(this);
483
+ this.handeleEndDateChange = this.handeleEndDateChange.bind(this);
484
+ this.handleTimeStartChange = this.handleTimeStartChange.bind(this);
485
+ this.handleTimeEndChange = this.handleTimeEndChange.bind(this);
283
486
  this.handleFocus = this.handleFocus.bind(this);
284
487
  this.handleBlur = this.handleBlur.bind(this);
285
488
  this.checkStartIsValidDate = this.checkStartIsValidDate.bind(this);
@@ -293,22 +496,63 @@ export class DateRangePicker extends React.Component<
293
496
  this.renderDay = this.renderDay.bind(this);
294
497
  this.renderQuarter = this.renderQuarter.bind(this);
295
498
  this.handleMobileChange = this.handleMobileChange.bind(this);
296
- const {format, joinValues, delimiter, value} = this.props;
297
-
499
+ this.handleOutClick = this.handleOutClick.bind(this);
500
+ const {format, joinValues, delimiter, value, inputFormat} = this.props;
501
+ const {startDate, endDate} = DateRangePicker.unFormatValue(
502
+ value,
503
+ format,
504
+ joinValues,
505
+ delimiter
506
+ );
298
507
  this.state = {
299
508
  isOpened: false,
300
509
  isFocused: false,
301
- ...DateRangePicker.unFormatValue(value, format, joinValues, delimiter)
510
+ startDate,
511
+ endDate,
512
+ startInputValue: startDate?.format(inputFormat),
513
+ endInputValue: endDate?.format(inputFormat)
302
514
  };
303
515
  }
516
+ componentDidMount() {
517
+ document.body.addEventListener('click', this.handleOutClick, true);
518
+ }
519
+
520
+ componentWillUnmount() {
521
+ document.body.removeEventListener('click', this.handleOutClick, true);
522
+ }
523
+
524
+ handleOutClick(e: Event) {
525
+ if (
526
+ !e.target ||
527
+ !this.dom.current ||
528
+ this.dom.current.contains(e.target as HTMLElement) ||
529
+ !this.calendarRef.current ||
530
+ this.calendarRef.current.contains(e.target as HTMLElement)
531
+ ) {
532
+ return;
533
+ }
534
+ if (this.state.isOpened) {
535
+ e.preventDefault();
536
+ this.close();
537
+ }
538
+ }
304
539
 
305
540
  componentDidUpdate(prevProps: DateRangePickerProps) {
306
541
  const props = this.props;
307
- const {value, format, joinValues, delimiter} = props;
542
+ const {value, format, joinValues, inputFormat, delimiter} = props;
308
543
 
309
544
  if (prevProps.value !== value) {
545
+ const {startDate, endDate} = DateRangePicker.unFormatValue(
546
+ value,
547
+ format,
548
+ joinValues,
549
+ delimiter
550
+ );
310
551
  this.setState({
311
- ...DateRangePicker.unFormatValue(value, format, joinValues, delimiter)
552
+ startDate,
553
+ endDate,
554
+ startInputValue: startDate?.format(inputFormat),
555
+ endInputValue: endDate?.format(inputFormat)
312
556
  });
313
557
  }
314
558
  }
@@ -355,10 +599,31 @@ export class DateRangePicker extends React.Component<
355
599
  });
356
600
  }
357
601
 
602
+ openStart() {
603
+ if (this.props.disabled) {
604
+ return;
605
+ }
606
+ this.setState({
607
+ isOpened: true,
608
+ editState: 'start'
609
+ });
610
+ }
611
+
612
+ openEnd() {
613
+ if (this.props.disabled) {
614
+ return;
615
+ }
616
+ this.setState({
617
+ isOpened: true,
618
+ editState: 'end'
619
+ });
620
+ }
621
+
358
622
  close() {
359
623
  this.setState(
360
624
  {
361
- isOpened: false
625
+ isOpened: false,
626
+ editState: undefined
362
627
  },
363
628
  this.blur
364
629
  );
@@ -428,55 +693,223 @@ export class DateRangePicker extends React.Component<
428
693
  return value;
429
694
  }
430
695
 
431
- handleSelectChange(newValue: moment.Moment) {
432
- const {embed, timeFormat, minDuration, maxDuration, minDate} = this.props;
696
+ handleDateChange(newValue: moment.Moment) {
697
+ let {editState} = this.state;
698
+ if (editState === 'start') {
699
+ this.handleStartDateChange(newValue);
700
+ } else if (editState === 'end') {
701
+ this.handeleEndDateChange(newValue);
702
+ }
703
+ }
704
+
705
+ handleStartDateChange(newValue: moment.Moment) {
706
+ const {timeFormat, minDate, inputFormat, type} = this.props;
707
+ let {startDate} = this.state;
708
+ if (minDate && newValue.isBefore(minDate)) {
709
+ newValue = minDate;
710
+ }
711
+ const date = this.filterDate(
712
+ newValue,
713
+ startDate || minDate,
714
+ timeFormat,
715
+ 'start'
716
+ );
717
+ const newState = {
718
+ startDate: date,
719
+ startInputValue: date.format(inputFormat)
720
+ } as any;
721
+ // 这些没有时间的选择点第一次后第二次就是选结束时间
722
+ if (
723
+ type === 'input-date-range' ||
724
+ type === 'input-year-range' ||
725
+ type === 'input-quarter-range'
726
+ ) {
727
+ newState.editState = 'end';
728
+ }
729
+ this.setState(newState);
730
+ }
731
+
732
+ handeleEndDateChange(newValue: moment.Moment) {
733
+ const {embed, timeFormat, inputFormat} = this.props;
433
734
  let {startDate, endDate} = this.state;
735
+ newValue = this.getEndDateByDuration(newValue);
434
736
 
435
- // 第一次点击只标记起始时间,或者点击了开始时间前面的时间
436
- if (this.isFirstClick || newValue.isBefore(startDate)) {
437
- // 这种情况说明第二次点击点击了前面的时间,这时要标记为第二次点击
438
- if (newValue.isBefore(startDate)) {
439
- this.isFirstClick = true;
440
- }
441
- if (minDate && newValue.isBefore(minDate)) {
442
- newValue = minDate;
443
- }
737
+ // 如果结束时间在前面,需要清空开始时间
738
+ if (newValue.isBefore(startDate)) {
444
739
  this.setState({
445
- startDate: this.filterDate(
446
- newValue,
447
- startDate || minDate,
448
- timeFormat,
449
- 'start'
450
- ),
451
- endDate: undefined
740
+ startDate: undefined,
741
+ startInputValue: ''
452
742
  });
453
- } else {
454
- // 第二次点击作为结束时间
455
- if (!startDate) {
456
- // 不大可能,但只能作为开始时间了
457
- startDate = newValue;
458
- }
743
+ }
459
744
 
460
- if (minDuration && newValue.isAfter(startDate.clone().add(minDuration))) {
461
- newValue = startDate.clone().add(minDuration);
745
+ const date = this.filterDate(newValue, endDate, timeFormat, 'end');
746
+ this.setState(
747
+ {
748
+ endDate: date,
749
+ endInputValue: date.format(inputFormat)
750
+ },
751
+ () => {
752
+ embed && this.confirm();
462
753
  }
463
- if (
464
- maxDuration &&
465
- newValue.isBefore(startDate.clone().add(maxDuration))
466
- ) {
467
- newValue = startDate.clone().add(maxDuration);
754
+ );
755
+ }
756
+
757
+ // 手动控制输入时间
758
+ startInputChange(e: React.ChangeEvent<HTMLInputElement>) {
759
+ const {onChange, inputFormat, format, utc} = this.props;
760
+ const value = e.currentTarget.value;
761
+ this.setState({startInputValue: value});
762
+ if (value === '') {
763
+ onChange('');
764
+ } else {
765
+ let newDate = this.getStartDateByDuration(moment(value, inputFormat));
766
+ this.setState({startDate: newDate});
767
+ }
768
+ }
769
+
770
+ endInputChange(e: React.ChangeEvent<HTMLInputElement>) {
771
+ const {onChange, inputFormat, format, utc} = this.props;
772
+ const value = e.currentTarget.value;
773
+ this.setState({endInputValue: value});
774
+ if (value === '') {
775
+ onChange('');
776
+ } else {
777
+ let newDate = this.getEndDateByDuration(moment(value, inputFormat));
778
+ this.setState({endDate: newDate});
779
+ }
780
+ }
781
+
782
+ // 根据 duration 修复结束时间
783
+ getEndDateByDuration(newValue: moment.Moment) {
784
+ const {minDuration, maxDuration, type} = this.props;
785
+ let {startDate, endDate, editState} = this.state;
786
+ if (!startDate) {
787
+ return newValue;
788
+ }
789
+
790
+ // 时间范围必须统一成同一天,不然会不一致
791
+ if (type === 'input-time-range' && startDate) {
792
+ newValue.set({
793
+ year: startDate.year(),
794
+ month: startDate.month(),
795
+ date: startDate.date()
796
+ });
797
+ }
798
+
799
+ if (minDuration && newValue.isBefore(startDate.clone().add(minDuration))) {
800
+ newValue = startDate.clone().add(minDuration);
801
+ }
802
+
803
+ if (maxDuration && newValue.isAfter(startDate.clone().add(maxDuration))) {
804
+ newValue = startDate.clone().add(maxDuration);
805
+ }
806
+
807
+ return newValue;
808
+ }
809
+
810
+ // 根据 duration 修复起始时间
811
+ getStartDateByDuration(newValue: moment.Moment) {
812
+ const {minDuration, maxDuration, type} = this.props;
813
+ let {endDate, editState} = this.state;
814
+ if (!endDate) {
815
+ return newValue;
816
+ }
817
+ // 时间范围必须统一成同一天,不然会不一致
818
+ if (type === 'input-time-range' && endDate) {
819
+ newValue.set({
820
+ year: endDate.year(),
821
+ month: endDate.month(),
822
+ date: endDate.date()
823
+ });
824
+ }
825
+
826
+ if (
827
+ minDuration &&
828
+ newValue.isBefore(endDate.clone().subtract(minDuration))
829
+ ) {
830
+ newValue = endDate.clone().subtract(minDuration);
831
+ }
832
+
833
+ if (
834
+ maxDuration &&
835
+ newValue.isAfter(endDate.clone().subtract(maxDuration))
836
+ ) {
837
+ newValue = endDate.clone().subtract(maxDuration);
838
+ }
839
+
840
+ return newValue;
841
+ }
842
+
843
+ // 主要用于处理时间的情况
844
+ handleTimeStartChange(newValue: moment.Moment) {
845
+ const {embed, timeFormat, inputFormat, minDuration, maxDuration, minDate} =
846
+ this.props;
847
+ const {startDate, endDate} = this.state;
848
+
849
+ // 时间范围必须统一成同一天,不然会不一致
850
+ if (endDate) {
851
+ newValue.set({
852
+ year: endDate.year(),
853
+ month: endDate.month(),
854
+ date: endDate.date()
855
+ });
856
+ }
857
+
858
+ if (minDate && newValue && newValue.isBefore(minDate, 'second')) {
859
+ newValue = minDate;
860
+ }
861
+
862
+ this.setState(
863
+ {
864
+ startDate: newValue,
865
+ startInputValue: newValue.format(inputFormat)
866
+ },
867
+ () => {
868
+ embed && this.confirm();
468
869
  }
469
- this.setState(
470
- {
471
- endDate: this.filterDate(newValue, endDate, timeFormat, 'end')
472
- },
473
- () => {
474
- embed && this.confirm();
475
- }
476
- );
870
+ );
871
+ }
872
+
873
+ handleTimeEndChange(newValue: moment.Moment) {
874
+ const {embed, timeFormat, inputFormat, minDuration, maxDuration, maxDate} =
875
+ this.props;
876
+ const {startDate, endDate} = this.state;
877
+ if (startDate) {
878
+ newValue.set({
879
+ year: startDate.year(),
880
+ month: startDate.month(),
881
+ date: startDate.date()
882
+ });
883
+ }
884
+
885
+ if (maxDate && newValue && newValue.isAfter(maxDate, 'second')) {
886
+ newValue = maxDate;
887
+ }
888
+
889
+ if (
890
+ startDate &&
891
+ minDuration &&
892
+ newValue.isAfter(startDate.clone().add(minDuration))
893
+ ) {
894
+ newValue = startDate.clone().add(minDuration);
895
+ }
896
+ if (
897
+ startDate &&
898
+ maxDuration &&
899
+ newValue.isBefore(startDate.clone().add(maxDuration))
900
+ ) {
901
+ newValue = startDate.clone().add(maxDuration);
477
902
  }
478
903
 
479
- this.isFirstClick = !this.isFirstClick;
904
+ this.setState(
905
+ {
906
+ endDate: newValue,
907
+ endInputValue: newValue.format(inputFormat)
908
+ },
909
+ () => {
910
+ embed && this.confirm();
911
+ }
912
+ );
480
913
  }
481
914
 
482
915
  handleMobileChange(data: any, callback?: () => void) {
@@ -528,8 +961,20 @@ export class DateRangePicker extends React.Component<
528
961
  }
529
962
  let range: PlainObject = {};
530
963
  if (typeof item === 'string') {
531
- range = availableRanges[item];
532
- range.key = item;
964
+ if (availableRanges[item]) {
965
+ range = availableRanges[item];
966
+ range.key = item;
967
+ } else {
968
+ // 通过正则尝试匹配
969
+ for (let i = 0, len = advancedRanges.length; i < len; i++) {
970
+ let value = advancedRanges[i];
971
+ const m = value.regexp.exec(item);
972
+ if (m) {
973
+ range = value.resolve.apply(item, [__, ...m]);
974
+ range.key = item;
975
+ }
976
+ }
977
+ }
533
978
  } else if (
534
979
  (item as ShortCutDateRange).startDate &&
535
980
  (item as ShortCutDateRange).endDate
@@ -558,7 +1003,7 @@ export class DateRangePicker extends React.Component<
558
1003
  e.preventDefault();
559
1004
  e.stopPropagation();
560
1005
  const {resetValue, onChange} = this.props;
561
-
1006
+ this.setState({startInputValue: '', endInputValue: ''});
562
1007
  onChange(resetValue);
563
1008
  }
564
1009
 
@@ -672,19 +1117,28 @@ export class DateRangePicker extends React.Component<
672
1117
  ranges,
673
1118
  locale,
674
1119
  embed,
1120
+ type,
675
1121
  viewMode = 'days'
676
1122
  } = this.props;
677
1123
  const __ = this.props.translate;
678
1124
 
679
1125
  const {startDate, endDate} = this.state;
1126
+
680
1127
  return (
681
- <div className={`${ns}DateRangePicker-wrap`}>
1128
+ <div className={`${ns}DateRangePicker-wrap`} ref={this.calendarRef}>
682
1129
  {this.renderRanges(ranges)}
683
-
684
1130
  <Calendar
685
1131
  className={`${ns}DateRangePicker-start`}
686
1132
  value={startDate}
687
- onChange={this.handleSelectChange}
1133
+ // 区分的原因是 time-range 左侧就只能选起始时间,而其它都能在左侧同时同时选择起始和结束
1134
+ // TODO: 后续得把 time-range 代码拆分出来
1135
+ onChange={
1136
+ type === 'input-datetime-range'
1137
+ ? this.handleStartDateChange
1138
+ : viewMode === 'time'
1139
+ ? this.handleTimeStartChange
1140
+ : this.handleDateChange
1141
+ }
688
1142
  requiredConfirm={false}
689
1143
  dateFormat={dateFormat}
690
1144
  inputFormat={inputFormat}
@@ -697,11 +1151,16 @@ export class DateRangePicker extends React.Component<
697
1151
  renderQuarter={this.renderQuarter}
698
1152
  locale={locale}
699
1153
  />
700
-
701
1154
  <Calendar
702
1155
  className={`${ns}DateRangePicker-end`}
703
1156
  value={endDate}
704
- onChange={this.handleSelectChange}
1157
+ onChange={
1158
+ type === 'input-datetime-range'
1159
+ ? this.handeleEndDateChange
1160
+ : viewMode === 'time'
1161
+ ? this.handleTimeEndChange
1162
+ : this.handleDateChange
1163
+ }
705
1164
  requiredConfirm={false}
706
1165
  dateFormat={dateFormat}
707
1166
  inputFormat={inputFormat}
@@ -724,7 +1183,10 @@ export class DateRangePicker extends React.Component<
724
1183
  </a>
725
1184
  <a
726
1185
  className={cx('Button', 'Button--primary', 'm-l-sm', {
727
- 'is-disabled': !this.state.startDate || !this.state.endDate
1186
+ 'is-disabled':
1187
+ !this.state.startDate ||
1188
+ !this.state.endDate ||
1189
+ this.state.endDate?.isBefore(this.state.startDate)
728
1190
  })}
729
1191
  onClick={this.confirm}
730
1192
  >
@@ -741,8 +1203,10 @@ export class DateRangePicker extends React.Component<
741
1203
  className,
742
1204
  popoverClassName,
743
1205
  classPrefix: ns,
1206
+ classnames: cx,
744
1207
  value,
745
- placeholder,
1208
+ startPlaceholder,
1209
+ endPlaceholder,
746
1210
  popOverContainer,
747
1211
  inputFormat,
748
1212
  format,
@@ -770,21 +1234,6 @@ export class DateRangePicker extends React.Component<
770
1234
 
771
1235
  const {isOpened, isFocused, startDate, endDate} = this.state;
772
1236
 
773
- const selectedDate = DateRangePicker.unFormatValue(
774
- value,
775
- format,
776
- joinValues,
777
- delimiter
778
- );
779
- const startViewValue = selectedDate.startDate
780
- ? selectedDate.startDate.format(inputFormat)
781
- : '';
782
- const endViewValue = selectedDate.endDate
783
- ? selectedDate.endDate.format(inputFormat)
784
- : '';
785
- const arr = [];
786
- startViewValue && arr.push(startViewValue);
787
- endViewValue && arr.push(endViewValue);
788
1237
  const __ = this.props.translate;
789
1238
 
790
1239
  const calendarMobile = (
@@ -849,17 +1298,32 @@ export class DateRangePicker extends React.Component<
849
1298
  className
850
1299
  )}
851
1300
  ref={this.dom}
852
- onClick={this.handleClick}
853
1301
  >
854
- {arr.length ? (
855
- <span className={`${ns}DateRangePicker-value`}>
856
- {arr.join(__('DateRange.valueConcat'))}
857
- </span>
858
- ) : (
859
- <span className={`${ns}DateRangePicker-placeholder`}>
860
- {__(placeholder)}
861
- </span>
862
- )}
1302
+ <Input
1303
+ className={cx('DateRangePicker-input', {
1304
+ isActive: this.state.editState === 'start'
1305
+ })}
1306
+ onChange={this.startInputChange}
1307
+ onClick={this.openStart}
1308
+ ref={this.startInputRef}
1309
+ placeholder={__(startPlaceholder)}
1310
+ autoComplete="off"
1311
+ value={this.state.startInputValue || ''}
1312
+ disabled={disabled}
1313
+ />
1314
+ <span className={cx('DateRangePicker-input-separator')}>~</span>
1315
+ <Input
1316
+ className={cx('DateRangePicker-input', {
1317
+ isActive: this.state.editState === 'end'
1318
+ })}
1319
+ onChange={this.endInputChange}
1320
+ onClick={this.openEnd}
1321
+ ref={this.endInputRef}
1322
+ placeholder={__(endPlaceholder)}
1323
+ autoComplete="off"
1324
+ value={this.state.endInputValue || ''}
1325
+ disabled={disabled}
1326
+ />
863
1327
 
864
1328
  {clearable && !disabled && value ? (
865
1329
  <a className={`${ns}DateRangePicker-clear`} onClick={this.clearValue}>
@@ -896,7 +1360,6 @@ export class DateRangePicker extends React.Component<
896
1360
  className={cx(`${ns}DateRangePicker-popover`, popoverClassName)}
897
1361
  onHide={this.close}
898
1362
  onClick={this.handlePopOverClick}
899
- overlay
900
1363
  >
901
1364
  {this.renderCalendar()}
902
1365
  </PopOver>