@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.
- package/es/_util/SwitchVersion.js +40 -0
- package/es/_util/depreactedPropsCompat.js +58 -0
- package/es/_util/index.js +31 -0
- package/es/_util/warning.js +2 -2
- package/es/alert/Alert.js +126 -0
- package/es/alert/__tests__/index.test.js +84 -0
- package/es/alert/index.js +6 -147
- package/es/alert/style/index.css +1 -1
- package/es/badge/Badge.js +82 -0
- package/es/badge/__tests__/index.test.js +82 -0
- package/es/badge/index.js +9 -87
- package/es/badge/style/index.css +1 -1
- package/es/badge/style/index.js +0 -0
- package/es/breadcrumb/__tests__/index.test.js +61 -0
- package/es/breadcrumb/index.js +85 -0
- package/es/breadcrumb/style/index.css +1 -0
- package/es/button/Button.js +62 -60
- package/es/button/ButtonGroup.js +24 -40
- package/es/button/IconLoading.js +6 -6
- package/es/button/__tests__/index.test.js +221 -0
- package/es/button/index.js +3 -2
- package/es/button/style/index.css +1 -1
- package/es/card/__tests__/index.test.js +179 -0
- package/es/card/index.js +61 -57
- package/es/card/style/index.css +1 -1
- package/es/carousel/__tests__/index.test.js +104 -0
- package/es/carousel/index.js +219 -0
- package/es/carousel/style/index.css +1 -0
- package/es/carousel/style/index.js +3 -0
- package/es/cascader/Cascader.js +190 -133
- package/es/cascader/Menu.js +168 -0
- package/es/cascader/__tests__/index.test.js +392 -0
- package/es/cascader/index.js +5 -2
- package/es/cascader/style/cascader.css +1 -1
- package/es/cascader/style/menu.css +1 -1
- package/es/checkbox/Checkbox.js +136 -0
- package/es/checkbox/Group.js +194 -0
- package/es/checkbox/__tests__/index.test.js +226 -0
- package/es/checkbox/checkbox-legacy/Base.js +212 -0
- package/es/checkbox/checkbox-legacy/CheckBox.js +157 -0
- package/es/checkbox/checkbox-legacy/index.js +15 -0
- package/es/checkbox/checkbox-legacy/style/index.css +1 -0
- package/es/checkbox/checkbox-legacy/style/index.js +3 -0
- package/es/checkbox/index.js +13 -4
- package/es/checkbox/style/index.css +1 -1
- package/es/collapse/__tests__/index.test.js +111 -0
- package/es/collapse/index.js +88 -110
- package/es/collapse/style/index.css +1 -1
- package/es/confirm/index.js +39 -60
- package/es/context/index.js +45 -51
- package/es/counter/Counter.js +339 -0
- package/es/counter/__tests__/index.test.js +134 -0
- package/es/counter/counter-legacy/index.js +267 -0
- package/es/counter/index.js +6 -270
- package/es/counter/style/index.css +1 -1
- package/es/date-picker/BasePicker.js +380 -302
- package/es/date-picker/Calender.js +326 -98
- package/es/date-picker/DatePanel.js +194 -213
- package/es/date-picker/DatePicker.js +143 -47
- package/es/date-picker/DateRangePanel.js +272 -208
- package/es/date-picker/Modal.js +18 -32
- package/es/date-picker/Time.js +231 -345
- package/es/date-picker/TimeList.js +246 -0
- package/es/date-picker/TimePanel.js +28 -41
- package/es/date-picker/TimePeriodPanel.js +27 -46
- package/es/date-picker/TimePicker.js +44 -46
- package/es/date-picker/TimeRangePanel.js +33 -51
- package/es/date-picker/Type.js +5 -1
- package/es/date-picker/WeekRangePanel.js +254 -175
- package/es/date-picker/YMRangePanel.js +364 -0
- package/es/date-picker/__tests__/index.test.js +956 -0
- package/es/date-picker/constants.js +14 -28
- package/es/date-picker/dateUtil.js +221 -52
- package/es/date-picker/datepicker-legacy/BasePicker.js +511 -0
- package/es/date-picker/datepicker-legacy/Calender.js +422 -0
- package/es/date-picker/datepicker-legacy/DatePanel.js +455 -0
- package/es/date-picker/datepicker-legacy/DatePicker.js +103 -0
- package/es/date-picker/datepicker-legacy/DateRangePanel.js +488 -0
- package/es/date-picker/datepicker-legacy/Modal.js +67 -0
- package/es/date-picker/datepicker-legacy/Time.js +405 -0
- package/es/date-picker/datepicker-legacy/TimePanel.js +85 -0
- package/es/date-picker/datepicker-legacy/TimePeriodPanel.js +118 -0
- package/es/date-picker/datepicker-legacy/TimePicker.js +78 -0
- package/es/date-picker/datepicker-legacy/TimeRangePanel.js +90 -0
- package/es/date-picker/datepicker-legacy/Type.js +31 -0
- package/es/date-picker/datepicker-legacy/WeekRangePanel.js +337 -0
- package/es/date-picker/datepicker-legacy/constants.js +79 -0
- package/es/date-picker/datepicker-legacy/dateUtil.js +258 -0
- package/es/date-picker/datepicker-legacy/index.js +15 -0
- package/es/date-picker/datepicker-legacy/local.js +11 -0
- package/es/date-picker/datepicker-legacy/style/index.css +1 -0
- package/es/date-picker/datepicker-legacy/style/index.js +3 -0
- package/es/date-picker/datepicker-legacy/style/timepicker.css +1 -0
- package/es/date-picker/datepicker-legacy/util.js +60 -0
- package/es/date-picker/index.js +5 -2
- package/es/date-picker/style/index.css +1 -1
- package/es/date-picker/toLunar.js +172 -0
- package/es/date-picker/util.js +101 -8
- package/es/dropdown/Dropdown.js +191 -203
- package/es/dropdown/DropdownButton.js +102 -0
- package/es/dropdown/DropdownMenu.js +107 -0
- package/es/dropdown/DropdownMenuItem.js +172 -0
- package/es/dropdown/__tests__/index.test.js +313 -0
- package/es/dropdown/index.js +69 -4
- package/es/dropdown/style/index.css +1 -1
- package/es/dropdown/style/index.js +0 -2
- package/es/dropdown/{__test__ → tests}/index.test.js +7 -7
- package/es/dropdown/utils.js +35 -0
- package/es/ficon/index.js +16 -30
- package/es/form/Form.js +176 -0
- package/es/form/{item.js → Item.js} +52 -60
- package/es/form/__tests__/index.test.js +571 -0
- package/es/form/index.js +6 -171
- package/es/form/style/index.css +1 -1
- package/es/grid/__tests__/index.test.js +100 -0
- package/es/grid/index.js +36 -56
- package/es/icon/index.js +23 -38
- package/es/index.js +61 -9
- package/es/input/Input.js +400 -0
- package/es/input/__tests__/index.test.js +376 -0
- package/es/input/index.js +26 -347
- package/es/input/input-legacy/index.js +341 -0
- package/es/input/input-legacy/util.js +176 -0
- package/es/input/style/index.css +1 -1
- package/es/input/util.js +26 -18
- package/es/lib/withDragDropContext.js +2 -2
- package/es/loading/Loading.js +173 -0
- package/es/loading/__tests__/index.test.js +110 -0
- package/es/loading/index.js +5 -129
- package/es/loading/style/index.css +0 -0
- package/es/loading/style/index.js +0 -0
- package/es/locales/en-US.js +45 -9
- package/es/locales/index.js +16 -2
- package/es/locales/zh-CN.js +46 -10
- package/es/locales/zh-Hant-HK.js +123 -0
- package/es/locales/zh-Hant-TW.js +125 -0
- package/es/menu/Item.js +34 -51
- package/es/menu/Menu.js +414 -0
- package/es/menu/SubMenu.js +63 -90
- package/es/menu/Title.js +37 -51
- package/es/menu/__tests__/index.test.js +274 -0
- package/es/menu/index.js +12 -419
- package/es/menu/style/index.css +1 -1
- package/es/message/__tests__/index.test.js +71 -0
- package/es/message/index.js +58 -0
- package/es/message/style/index.css +1 -0
- package/es/message/style/index.js +5 -0
- package/es/modal/__tests__/index.test.js +178 -0
- package/es/modal/index.js +85 -77
- package/es/modal/style/index.css +1 -1
- package/es/nav-menu/NavMenu.js +44 -61
- package/es/nav-menu/__test__/index.test.js +8 -8
- package/es/nav-menu/__tests__/index.test.js +23 -0
- package/es/nav-menu/index.js +2 -2
- package/es/notice/Notice.js +136 -0
- package/es/notice/NoticeContainer.js +107 -0
- package/es/notice/__tests__/index.test.js +174 -0
- package/es/notice/index.js +66 -0
- package/es/notice/style/index.css +1 -0
- package/es/notice/style/index.js +5 -0
- package/es/notification/HandleNotification/index.js +216 -0
- package/es/notification/HandleNotification/style/index.css +1 -0
- package/es/notification/HandleNotification/style/index.js +5 -0
- package/es/notification/__tests__/index.test.js +114 -0
- package/es/notification/index.js +68 -231
- package/es/notification/style/index.css +1 -1
- package/es/notification/style/index.js +0 -0
- package/es/pagination/Pager.js +7 -9
- package/es/pagination/Pagination.js +134 -133
- package/es/pagination/__tests__/index.test.js +244 -0
- package/es/pagination/index.js +9 -8
- package/es/pagination/style/index.css +1 -1
- package/es/panel/index.js +28 -46
- package/es/popover/__test__/index.test.js +10 -10
- package/es/popover/__tests__/index.test.js +152 -0
- package/es/popover/index.js +77 -83
- package/es/popper/index.js +68 -64
- package/es/popper/style/index.css +1 -1
- package/es/preview/index.js +529 -0
- package/es/preview/style/index.css +1 -0
- package/es/preview/style/index.js +3 -0
- package/es/progress/BarProgress.js +107 -43
- package/es/progress/CircleProgress.js +13 -14
- package/es/progress/DashboardProgress.js +11 -13
- package/es/progress/Progress.js +102 -0
- package/es/progress/__tests__/index.test.js +131 -0
- package/es/progress/index.js +8 -100
- package/es/progress/style/index.css +1 -1
- package/es/radio/Group.js +199 -0
- package/es/radio/Radio.js +147 -0
- package/es/radio/__tests__/index.test.js +127 -0
- package/es/radio/index.js +10 -216
- package/es/radio/{__test__ → radio-legacy/__test__}/index.test.js +13 -13
- package/es/radio/radio-legacy/index.js +214 -0
- package/es/radio/radio-legacy/style/index.css +1 -0
- package/es/radio/radio-legacy/style/index.js +3 -0
- package/es/radio/style/index.css +1 -1
- package/es/rate/Icons.js +70 -70
- package/es/rate/Rate.js +75 -108
- package/es/rate/__tests__/index.test.js +124 -0
- package/es/rate/index.js +5 -2
- package/es/rate/style/index.css +1 -1
- package/es/select/Select.js +330 -265
- package/es/select/SelectDropdown.js +223 -79
- package/es/select/SelectInput.js +120 -91
- package/es/select/__tests__/index.test.js +505 -0
- package/es/select/index.js +6 -4
- package/es/select/select-legacy/Option.js +78 -0
- package/es/select/select-legacy/Select.js +702 -0
- package/es/select/select-legacy/SelectDropdown.js +157 -0
- package/es/select/select-legacy/SelectInput.js +308 -0
- package/es/select/select-legacy/common.js +19 -0
- package/es/select/select-legacy/index.js +16 -0
- package/es/select/style/select-dropdown.css +1 -1
- package/es/select/style/select-input.css +1 -1
- package/es/stepper/Stepper.js +147 -0
- package/es/stepper/__tests__/index.test.js +161 -0
- package/es/stepper/index.js +21 -127
- package/es/stepper/style/index.css +1 -1
- package/es/style/icon/diyIcon.css +1 -1
- package/es/style/icon/index.css +1 -1
- package/es/switch/__tests__/index.test.js +68 -0
- package/es/switch/index.js +26 -46
- package/es/switch/style/index.css +1 -1
- package/es/table/Body.js +294 -0
- package/es/table/ClickOuterside.js +95 -0
- package/es/table/Footer.js +171 -0
- package/es/table/Header.js +320 -0
- package/es/table/TableContent.js +101 -0
- package/es/table/__tests__/index.test.js +129 -0
- package/es/table/checkbox/index.js +36 -47
- package/es/table/checkbox/style/index.css +1 -0
- package/es/table/checkbox/style/index.js +3 -0
- package/es/table/index.js +269 -314
- package/es/table/menu/index.js +34 -44
- package/es/table/prefix.js +2 -2
- package/es/table/style/Table.css +1 -1
- package/es/table/style/index.css +1 -1
- package/es/tabs/ItemDropdown.js +45 -65
- package/es/tabs/TabPane.js +26 -44
- package/es/tabs/Tabs.js +110 -111
- package/es/tabs/__tests__/index.test.js +329 -0
- package/es/tabs/index.js +9 -3
- package/es/tabs/style/index.css +1 -1
- package/es/tabs/tabs-legacy/ItemDropdown.js +162 -0
- package/es/tabs/tabs-legacy/TabPane.js +70 -0
- package/es/tabs/tabs-legacy/Tabs.js +291 -0
- package/es/tabs/tabs-legacy/index.js +18 -0
- package/es/tabs/tabs-legacy/style/index.css +1 -0
- package/es/tabs/tabs-legacy/style/index.js +3 -0
- package/es/tag/__tests__/index.test.js +46 -0
- package/es/tag/index.js +86 -0
- package/es/tag/style/index.css +1 -0
- package/es/tag/style/index.js +3 -0
- package/es/timeline/__tests__/index.test.js +198 -0
- package/es/timeline/index.js +206 -136
- package/es/timeline/style/index.css +1 -1
- package/es/tooltip/__tests__/index.test.js +166 -0
- package/es/tooltip/index.js +93 -52
- package/es/tooltip/style/index.css +1 -1
- package/es/transfer/Item.js +73 -71
- package/es/transfer/Transfer.js +558 -0
- package/es/transfer/__tests__/index.test.js +210 -0
- package/es/transfer/index.js +4 -443
- package/es/transfer/style/index.css +1 -1
- package/es/tree/IconLoading.js +38 -0
- package/es/tree/Tree.js +94 -111
- package/es/tree/TreeDivider.js +6 -6
- package/es/tree/TreeItem.js +217 -123
- package/es/tree/TreeNode.js +472 -333
- package/es/tree/__tests__/index.test.js +599 -0
- package/es/tree/index.js +9 -2
- package/es/tree/style/index.css +1 -1
- package/es/tree/tree-legacy/Tree.js +330 -0
- package/es/tree/tree-legacy/TreeDivider.js +25 -0
- package/es/tree/tree-legacy/TreeItem.js +326 -0
- package/es/tree/tree-legacy/TreeNode.js +711 -0
- package/es/tree/tree-legacy/index.js +13 -0
- package/es/tree/tree-legacy/style/index.css +1 -0
- package/es/tree/tree-legacy/style/index.js +3 -0
- package/es/tree/tree-legacy/util.js +434 -0
- package/es/tree/util.js +8 -256
- package/es/upload/Upload.js +292 -200
- package/es/upload/UploadAvatar.js +61 -79
- package/es/upload/UploadClick.js +62 -60
- package/es/upload/UploadDrag.js +63 -66
- package/es/upload/UploadPhoto.js +86 -75
- package/es/upload/UploadPictureCard.js +53 -60
- package/es/upload/__tests__/index.test.js +760 -0
- package/es/upload/index.js +8 -71
- package/es/upload/main.js +83 -0
- package/es/upload/style/index.css +1 -1
- package/es/upload/tool.js +0 -1
- package/es/upload/{Preview.js → upload-legacy/Preview.js} +48 -62
- package/es/upload/upload-legacy/Upload.js +431 -0
- package/es/upload/upload-legacy/UploadAvatar.js +318 -0
- package/es/upload/upload-legacy/UploadClick.js +121 -0
- package/es/upload/upload-legacy/UploadDrag.js +176 -0
- package/es/upload/upload-legacy/UploadPhoto.js +179 -0
- package/es/upload/upload-legacy/UploadPictureCard.js +122 -0
- package/es/upload/upload-legacy/index.js +67 -0
- package/es/upload/upload-legacy/style/index.css +1 -0
- package/es/upload/upload-legacy/style/index.js +5 -0
- package/es/upload/upload-legacy/tool.js +84 -0
- package/es/watermark/index.js +97 -0
- package/es/watermark/watermark.js +263 -0
- package/package.json +1 -1
- package/es/alert/__test__/index.test.js +0 -67
- package/es/button/__test__/index.test.js +0 -29
- package/es/cascader/__test__/index.test.js +0 -283
- package/es/cascader/menu.js +0 -155
- package/es/checkbox/Base.js +0 -205
- package/es/checkbox/CheckBox.js +0 -185
- package/es/collapse/__test__/index.test.js +0 -58
- package/es/counter/__test__/index.test.js +0 -52
- package/es/menu/ItemGroup.js +0 -81
- package/es/modal/__test__/index.test.js +0 -123
- package/es/notification/__test__/index.test.js +0 -56
- package/es/pagination/__test__/index.test.js +0 -140
- package/es/rate/__test__/index.test.js +0 -54
- package/es/select/Option.js +0 -93
- package/es/select/__test__/index.test.js +0 -429
- package/es/style/color/colors.css +0 -0
- package/es/style/index.css +0 -0
- package/es/style/mixins/colors.css +0 -0
- package/es/style/mixins/index.css +0 -0
- package/es/style/theme/dark.css +0 -0
- package/es/style/theme/default.css +0 -0
- package/es/switch/__test__/index.test.js +0 -39
- package/es/table/__test__/index.test.js +0 -73
- package/es/table/body.js +0 -318
- package/es/table/clickOuterside.js +0 -115
- package/es/table/footer.js +0 -196
- package/es/table/header.js +0 -337
- package/es/table/pover.js +0 -154
- package/es/table/tableContent.js +0 -120
- package/es/timeline/__test__/index.test.js +0 -49
- package/es/timeline/foldingItem.js +0 -82
- package/es/tooltip/__test__/index.test.js +0 -67
- package/es/transfer/__test__/index.test.js +0 -11
- /package/es/{style → breadcrumb/style}/index.js +0 -0
- /package/es/checkbox/{common.js → checkbox-legacy/common.js} +0 -0
- /package/es/upload/{style → upload-legacy/style}/preview.css +0 -0
- /package/es/upload/{style → upload-legacy/style}/preview.js +0 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
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 _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
21
|
+
|
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
+
|
|
28
|
+
var _Modal = _interopRequireDefault(require("./Modal"));
|
|
29
|
+
|
|
30
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
31
|
+
|
|
32
|
+
var _constants = require("./constants");
|
|
33
|
+
|
|
34
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
35
|
+
|
|
36
|
+
var _Type = _interopRequireDefault(require("./Type"));
|
|
37
|
+
|
|
38
|
+
var _dateUtil = require("./dateUtil");
|
|
39
|
+
|
|
40
|
+
var _dateFns = require("date-fns");
|
|
41
|
+
|
|
42
|
+
var BasePicker =
|
|
43
|
+
/*#__PURE__*/
|
|
44
|
+
function (_Component) {
|
|
45
|
+
(0, _inherits2["default"])(BasePicker, _Component);
|
|
46
|
+
|
|
47
|
+
function BasePicker(props) {
|
|
48
|
+
var _this;
|
|
49
|
+
|
|
50
|
+
(0, _classCallCheck2["default"])(this, BasePicker);
|
|
51
|
+
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(BasePicker).call(this, props));
|
|
52
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRoot", null);
|
|
53
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "input", null);
|
|
54
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rInput", null);
|
|
55
|
+
_this.state = {
|
|
56
|
+
showPanel: false,
|
|
57
|
+
style: {},
|
|
58
|
+
date: null,
|
|
59
|
+
isFocus: false,
|
|
60
|
+
// input 框内的显示的时间内容
|
|
61
|
+
texts: ['', ''],
|
|
62
|
+
placeholder: '',
|
|
63
|
+
rText: '',
|
|
64
|
+
leftPlaceholder: '',
|
|
65
|
+
rightPlaceholder: '',
|
|
66
|
+
format: ''
|
|
67
|
+
};
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
(0, _createClass2["default"])(BasePicker, [{
|
|
72
|
+
key: "setPlaceholder",
|
|
73
|
+
value: function setPlaceholder() {
|
|
74
|
+
var _this$props = this.props,
|
|
75
|
+
placeholder = _this$props.placeholder,
|
|
76
|
+
localeDatas = _this$props.localeDatas,
|
|
77
|
+
type = _this$props.type;
|
|
78
|
+
var tempPlaceholder = localeDatas.datePicker.placeholders[type] || localeDatas.datePicker.placeholder;
|
|
79
|
+
var leftPlaceholder = tempPlaceholder;
|
|
80
|
+
var rightPlaceholder = tempPlaceholder;
|
|
81
|
+
|
|
82
|
+
if (placeholder instanceof Array) {
|
|
83
|
+
leftPlaceholder = placeholder[0];
|
|
84
|
+
rightPlaceholder = placeholder[1] || placeholder[0];
|
|
85
|
+
} else if (typeof placeholder === 'string') {
|
|
86
|
+
leftPlaceholder = placeholder;
|
|
87
|
+
rightPlaceholder = placeholder;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this.setState({
|
|
91
|
+
leftPlaceholder: leftPlaceholder,
|
|
92
|
+
rightPlaceholder: rightPlaceholder
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "_parseProps",
|
|
97
|
+
value: function _parseProps(props, callback) {
|
|
98
|
+
var _this2 = this;
|
|
99
|
+
|
|
100
|
+
var value = props.value,
|
|
101
|
+
showTime = props.showTime,
|
|
102
|
+
type = props.type,
|
|
103
|
+
format = props.format,
|
|
104
|
+
localeDatas = props.localeDatas,
|
|
105
|
+
weekOffset = props.weekOffset;
|
|
106
|
+
format = format || _constants.FORMATS[type];
|
|
107
|
+
var date = new Date(); // 当前时间
|
|
108
|
+
|
|
109
|
+
var noText = false;
|
|
110
|
+
/**
|
|
111
|
+
* value 可能的格式:
|
|
112
|
+
* '' | undefined | null | Date | String | Number | {start: xxx, end: xxx}
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
if (value === '' || !value) {
|
|
116
|
+
// value 未传入情况
|
|
117
|
+
date = new Date();
|
|
118
|
+
noText = true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (typeof value === 'number' || typeof value === 'string' && value.trim().length > 4) {
|
|
122
|
+
// value 为数字(times)
|
|
123
|
+
date = (0, _dateUtil.toDate)(value);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (value instanceof Date) {
|
|
127
|
+
date = value;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (type.includes('range') || type === 'timeperiod') {
|
|
131
|
+
if (value instanceof Date || !value) {
|
|
132
|
+
// 如果为时间段选择,则取默认的第一个范围
|
|
133
|
+
date = {
|
|
134
|
+
startDate: (0, _dateUtil.startOfDay)(date),
|
|
135
|
+
endDate: type === 'timeperiod' ? (0, _dateFns.addHours)((0, _dateUtil.startOfDay)(date), 4) : (0, _dateUtil.endOfDay)(date)
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (value && value.start && value.end) {
|
|
140
|
+
date = {
|
|
141
|
+
startDate: value.start,
|
|
142
|
+
endDate: value.end
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var leftText = noText ? '' : (0, _constants.formatterDate)(type, date.startDate || date, format, showTime, localeDatas, weekOffset);
|
|
148
|
+
var rightText = noText ? '' : (0, _constants.formatterDate)(type, date.endDate || date, format, showTime, localeDatas, weekOffset);
|
|
149
|
+
this.setState({
|
|
150
|
+
texts: [leftText, rightText],
|
|
151
|
+
date: date,
|
|
152
|
+
format: format
|
|
153
|
+
}, function () {
|
|
154
|
+
callback && callback(_this2.state.date);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "componentDidMount",
|
|
159
|
+
value: function componentDidMount() {
|
|
160
|
+
var _this3 = this;
|
|
161
|
+
|
|
162
|
+
this._parseProps(this.props, function (date) {
|
|
163
|
+
if (date.startDate && date.endDate) {
|
|
164
|
+
date = {
|
|
165
|
+
start: new Date(date.startDate),
|
|
166
|
+
end: new Date(date.endDate)
|
|
167
|
+
};
|
|
168
|
+
} else {
|
|
169
|
+
date = new Date(date);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
_this3.props.value && _this3.props.onChange && _this3.props.onChange(date);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
this.setPlaceholder();
|
|
176
|
+
var rect = this.inputRoot.getBoundingClientRect();
|
|
177
|
+
this.calcPanelPos(rect);
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
key: "calcPanelPos",
|
|
181
|
+
value: function calcPanelPos(rect) {
|
|
182
|
+
var _this$props2 = this.props,
|
|
183
|
+
showTime = _this$props2.showTime,
|
|
184
|
+
type = _this$props2.type;
|
|
185
|
+
|
|
186
|
+
var _w = type.indexOf('range') !== -1 ? 578 : 288;
|
|
187
|
+
|
|
188
|
+
var _h = 298;
|
|
189
|
+
|
|
190
|
+
if (type === 'daterange' && showTime) {
|
|
191
|
+
_h = 344;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var _cw = document.body.clientWidth || document.documentElement.clientWidth;
|
|
195
|
+
|
|
196
|
+
var _ch = document.body.clientHeight || document.documentElement.clientHeight;
|
|
197
|
+
|
|
198
|
+
var _st = document.body.scrollTop || document.documentElement.scrollTop;
|
|
199
|
+
|
|
200
|
+
var left = rect.left,
|
|
201
|
+
width = rect.width,
|
|
202
|
+
top = rect.top,
|
|
203
|
+
height = rect.height;
|
|
204
|
+
|
|
205
|
+
var _top = rect.top + rect.height + _st;
|
|
206
|
+
|
|
207
|
+
if (left + _w > _cw) {
|
|
208
|
+
left = left + width - _w;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (top + _h + height > _ch) {
|
|
212
|
+
_top = top - _h + _st;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
this.setState({
|
|
216
|
+
style: {
|
|
217
|
+
position: 'absolute',
|
|
218
|
+
left: left,
|
|
219
|
+
top: _top
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
key: "componentWillReceiveProps",
|
|
225
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
226
|
+
this._parseProps(nextProps);
|
|
227
|
+
}
|
|
228
|
+
}, {
|
|
229
|
+
key: "onPick",
|
|
230
|
+
value: function onPick(date, showPanel) {
|
|
231
|
+
var _this4 = this;
|
|
232
|
+
|
|
233
|
+
var _this$props3 = this.props,
|
|
234
|
+
type = _this$props3.type,
|
|
235
|
+
showTime = _this$props3.showTime,
|
|
236
|
+
localeDatas = _this$props3.localeDatas,
|
|
237
|
+
weekOffset = _this$props3.weekOffset;
|
|
238
|
+
var format = this.state.format;
|
|
239
|
+
this.setState({
|
|
240
|
+
date: date,
|
|
241
|
+
texts: [(0, _constants.formatterDate)(type, date.startDate || date, format, showTime, localeDatas, weekOffset), (0, _constants.formatterDate)(type, date.endDate, format, showTime, localeDatas, weekOffset)],
|
|
242
|
+
showPanel: showPanel,
|
|
243
|
+
isFocus: false
|
|
244
|
+
}, function () {
|
|
245
|
+
if (!showPanel) {
|
|
246
|
+
_this4.callback();
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "callback",
|
|
252
|
+
value: function callback() {
|
|
253
|
+
var _this$props4 = this.props,
|
|
254
|
+
type = _this$props4.type,
|
|
255
|
+
onChange = _this$props4.onChange,
|
|
256
|
+
weekOffset = _this$props4.weekOffset;
|
|
257
|
+
var date = this.state.date;
|
|
258
|
+
|
|
259
|
+
if (onChange) {
|
|
260
|
+
var startDate = date.startDate,
|
|
261
|
+
endDate = date.endDate;
|
|
262
|
+
var _weekOffset = {
|
|
263
|
+
weekStartsOn: weekOffset
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
if (type === 'week') {
|
|
267
|
+
onChange({
|
|
268
|
+
start: (0, _dateUtil.startOfWeek)(date, _weekOffset),
|
|
269
|
+
end: (0, _dateUtil.endOfWeek)(date, _weekOffset)
|
|
270
|
+
});
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (startDate && endDate) {
|
|
275
|
+
if (type === 'weekrange') {
|
|
276
|
+
onChange({
|
|
277
|
+
start: (0, _dateUtil.startOfWeek)(startDate, _weekOffset),
|
|
278
|
+
end: (0, _dateUtil.endOfWeek)(endDate, _weekOffset)
|
|
279
|
+
});
|
|
280
|
+
} else if (['timerange', 'timeperiod', 'daterange'].includes(type)) {
|
|
281
|
+
onChange({
|
|
282
|
+
start: startDate,
|
|
283
|
+
end: endDate
|
|
284
|
+
});
|
|
285
|
+
} else {
|
|
286
|
+
onChange({
|
|
287
|
+
start: (0, _dateUtil.startOfDay)(startDate),
|
|
288
|
+
end: (0, _dateUtil.endOfDay)(endDate)
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
onChange(date);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}, {
|
|
297
|
+
key: "timeCancel",
|
|
298
|
+
value: function timeCancel() {
|
|
299
|
+
var _this$state = this.state,
|
|
300
|
+
tempDate = _this$state.tempDate,
|
|
301
|
+
format = _this$state.format;
|
|
302
|
+
var _this$props5 = this.props,
|
|
303
|
+
type = _this$props5.type,
|
|
304
|
+
showTime = _this$props5.showTime,
|
|
305
|
+
localeDatas = _this$props5.localeDatas,
|
|
306
|
+
weekOffset = _this$props5.weekOffset;
|
|
307
|
+
|
|
308
|
+
if (tempDate) {
|
|
309
|
+
this.setState({
|
|
310
|
+
date: new Date(tempDate),
|
|
311
|
+
text: (0, _constants.formatterDate)(type, new Date(tempDate), format, showTime, localeDatas, weekOffset),
|
|
312
|
+
showPanel: false
|
|
313
|
+
});
|
|
314
|
+
} else {
|
|
315
|
+
this.setState({
|
|
316
|
+
showPanel: false,
|
|
317
|
+
isFocus: false
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
key: "clickOutSide",
|
|
323
|
+
value: function clickOutSide(e) {
|
|
324
|
+
var tar = e.target;
|
|
325
|
+
|
|
326
|
+
if (tar.className.indexOf('clear') !== -1) {
|
|
327
|
+
this.setState({
|
|
328
|
+
texts: ['', ''],
|
|
329
|
+
showPanel: false
|
|
330
|
+
});
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (tar !== this.input && tar !== this.rInput) {
|
|
335
|
+
this.timeCancel();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
this.callback();
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
key: "_input",
|
|
342
|
+
value: function _input(text) {
|
|
343
|
+
var _this5 = this;
|
|
344
|
+
|
|
345
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'input';
|
|
346
|
+
|
|
347
|
+
var placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Please Select...';
|
|
348
|
+
var _this$props6 = this.props,
|
|
349
|
+
disabled = _this$props6.disabled,
|
|
350
|
+
type = _this$props6.type,
|
|
351
|
+
_onChange = _this$props6.onChange;
|
|
352
|
+
return _react["default"].createElement("input", {
|
|
353
|
+
type: "text",
|
|
354
|
+
ref: function ref(el) {
|
|
355
|
+
_this5[_ref] = el;
|
|
356
|
+
},
|
|
357
|
+
placeholder: placeholder,
|
|
358
|
+
className: disabled ? 'disabled' : '',
|
|
359
|
+
disabled: disabled,
|
|
360
|
+
onChange: function onChange(e) {
|
|
361
|
+
(0, _constants.isVaildDate)(new Date(e.target.value)) && type === 'date' && _onChange(new Date(e.target.value));
|
|
362
|
+
|
|
363
|
+
_this5.setState({
|
|
364
|
+
text: e.target.value
|
|
365
|
+
});
|
|
366
|
+
},
|
|
367
|
+
onFocus: function onFocus(e) {
|
|
368
|
+
_this5.setState({
|
|
369
|
+
showPanel: true,
|
|
370
|
+
isFocus: true
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
_this5.calcPanelPos(_this5.inputRoot.getBoundingClientRect());
|
|
374
|
+
},
|
|
375
|
+
value: text
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}, {
|
|
379
|
+
key: "_clear",
|
|
380
|
+
value: function _clear() {
|
|
381
|
+
var onChange = this.props.onChange;
|
|
382
|
+
|
|
383
|
+
if (onChange) {
|
|
384
|
+
onChange(null);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
this.setState({
|
|
388
|
+
texts: ['', ''],
|
|
389
|
+
isFocus: false
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}, {
|
|
393
|
+
key: "_icon",
|
|
394
|
+
value: function _icon() {
|
|
395
|
+
var _this6 = this;
|
|
396
|
+
|
|
397
|
+
var isFocus = this.state.isFocus;
|
|
398
|
+
var iconCls = (0, _classnames["default"])('hi-datepicker-legacy__input-icon', 'hi-icon', isFocus ? 'icon-close-circle clear' : 'icon-date');
|
|
399
|
+
return isFocus ? _react["default"].createElement("span", {
|
|
400
|
+
className: iconCls,
|
|
401
|
+
onClick: this._clear.bind(this)
|
|
402
|
+
}) : _react["default"].createElement("span", {
|
|
403
|
+
className: iconCls,
|
|
404
|
+
onClick: function onClick(e) {
|
|
405
|
+
if (_this6.props.disabled) return;
|
|
406
|
+
|
|
407
|
+
_this6.calcPanelPos(_this6.inputRoot.getBoundingClientRect());
|
|
408
|
+
|
|
409
|
+
_this6.setState({
|
|
410
|
+
showPanel: true,
|
|
411
|
+
isFocus: true
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}, {
|
|
417
|
+
key: "renderRangeInput",
|
|
418
|
+
value: function renderRangeInput() {
|
|
419
|
+
var _this$props7 = this.props,
|
|
420
|
+
localeDatas = _this$props7.localeDatas,
|
|
421
|
+
disabled = _this$props7.disabled,
|
|
422
|
+
showTime = _this$props7.showTime;
|
|
423
|
+
|
|
424
|
+
var _cls = (0, _classnames["default"])('hi-datepicker-legacy__input', 'hi-datepicker-legacy__input--range', showTime && 'hi-datepicker-legacy__input--range-time', disabled && 'hi-datepicker-legacy__input--disabled');
|
|
425
|
+
|
|
426
|
+
return _react["default"].createElement("div", {
|
|
427
|
+
className: _cls
|
|
428
|
+
}, this._input(this.state.texts[0], 'input', this.state.leftPlaceholder), _react["default"].createElement("span", null, localeDatas.datePicker.to), this._input(this.state.texts[1], 'rInput', this.state.rightPlaceholder), this._icon());
|
|
429
|
+
}
|
|
430
|
+
}, {
|
|
431
|
+
key: "renderNormalInput",
|
|
432
|
+
value: function renderNormalInput() {
|
|
433
|
+
var _this$props8 = this.props,
|
|
434
|
+
disabled = _this$props8.disabled,
|
|
435
|
+
showTime = _this$props8.showTime;
|
|
436
|
+
|
|
437
|
+
var _cls = (0, _classnames["default"])('hi-datepicker-legacy__input', 'hi-datepicker-legacy__input--normal', disabled && 'hi-datepicker-legacy__input--disabled', showTime && 'hi-datepicker-legacy__input--middle');
|
|
438
|
+
|
|
439
|
+
return _react["default"].createElement("div", {
|
|
440
|
+
className: _cls
|
|
441
|
+
}, this._input(this.state.texts[0], 'input', this.state.leftPlaceholder), this._icon());
|
|
442
|
+
}
|
|
443
|
+
}, {
|
|
444
|
+
key: "render",
|
|
445
|
+
value: function render() {
|
|
446
|
+
var _this7 = this;
|
|
447
|
+
|
|
448
|
+
var _this$props9 = this.props,
|
|
449
|
+
type = _this$props9.type,
|
|
450
|
+
showTime = _this$props9.showTime;
|
|
451
|
+
return _react["default"].createElement("span", {
|
|
452
|
+
ref: function ref(el) {
|
|
453
|
+
_this7.inputRoot = el;
|
|
454
|
+
},
|
|
455
|
+
className: "hi-datepicker-legacy__input-root"
|
|
456
|
+
}, type.indexOf('range') !== -1 || type === 'timeperiod' ? this.renderRangeInput() : this.renderNormalInput(), this.state.showPanel ? _react["default"].createElement(_Modal["default"], {
|
|
457
|
+
clickOutSide: this.clickOutSide.bind(this),
|
|
458
|
+
showTime: showTime
|
|
459
|
+
}, this.initPanel(this.state, this.props)) : null);
|
|
460
|
+
}
|
|
461
|
+
}]);
|
|
462
|
+
return BasePicker;
|
|
463
|
+
}(_react.Component);
|
|
464
|
+
|
|
465
|
+
(0, _defineProperty2["default"])(BasePicker, "propTypes", {
|
|
466
|
+
type: _propTypes["default"].oneOf(Object.values(_Type["default"])),
|
|
467
|
+
value: function value(props, propName, componentName) {
|
|
468
|
+
// Invalid Date
|
|
469
|
+
var val = props[propName];
|
|
470
|
+
|
|
471
|
+
if (val === undefined || val === null) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (val.start && val.end) {
|
|
476
|
+
var _start = (0, _dateUtil.dateFormat)(val.start);
|
|
477
|
+
|
|
478
|
+
var _end = (0, _dateUtil.dateFormat)(val.end);
|
|
479
|
+
|
|
480
|
+
if (_start === 'Invalid Date' || _end === 'Invalid Date') {
|
|
481
|
+
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Validation failed. start or end is an invalid date."));
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
if ((0, _dateUtil.dateFormat)(val) === 'Invalid Date') {
|
|
485
|
+
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Validation failed. value is an invalid data."));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
onChange: _propTypes["default"].func,
|
|
490
|
+
format: _propTypes["default"].string,
|
|
491
|
+
showTime: _propTypes["default"].bool,
|
|
492
|
+
disabled: _propTypes["default"].bool,
|
|
493
|
+
showWeekNumber: _propTypes["default"].bool,
|
|
494
|
+
weekOffset: _propTypes["default"].oneOf([0, 1]),
|
|
495
|
+
timeInterval: function timeInterval(props, propName, componentName) {
|
|
496
|
+
var val = props[propName];
|
|
497
|
+
|
|
498
|
+
if (val < 5 || val > 480 || val > 60 && val % 60 !== 0 || val < 60 && 60 % val !== 0) {
|
|
499
|
+
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."));
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
(0, _defineProperty2["default"])(BasePicker, "defaultProps", {
|
|
504
|
+
type: 'date',
|
|
505
|
+
disabled: false,
|
|
506
|
+
showWeekNumber: true,
|
|
507
|
+
weekOffset: 0,
|
|
508
|
+
timeInterval: 240
|
|
509
|
+
});
|
|
510
|
+
var _default = BasePicker;
|
|
511
|
+
exports["default"] = _default;
|