@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
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
110
|
+
this._parseProps(this.props);
|
|
190
111
|
|
|
191
|
-
this.
|
|
192
|
-
|
|
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
|
-
|
|
257
|
-
|
|
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
|
|
260
|
-
_nextProps = _objectWithoutProperties(nextProps, ["onChange"]);
|
|
213
|
+
var _value = value || defaultValue;
|
|
261
214
|
|
|
262
|
-
|
|
263
|
-
|
|
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
|
|
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: [
|
|
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
|
-
|
|
275
|
+
_this2.callback();
|
|
285
276
|
}
|
|
286
277
|
});
|
|
287
278
|
}
|
|
288
279
|
}, {
|
|
289
280
|
key: "callback",
|
|
290
281
|
value: function callback() {
|
|
291
|
-
var _this$
|
|
292
|
-
type = _this$
|
|
293
|
-
onChange = _this$
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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 (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
357
|
-
|
|
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
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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 (
|
|
368
|
+
if (endDate && (0, _dateUtil.isValid)(endDate)) {
|
|
369
|
+
date.endDate && (date.endDate = endDate);
|
|
374
370
|
this.setState({
|
|
375
|
-
date:
|
|
376
|
-
text: (0, _constants.formatterDate)(type, new Date(tempDate), format, showTime, localeDatas, weekOffset),
|
|
377
|
-
showPanel: false
|
|
371
|
+
date: date
|
|
378
372
|
});
|
|
379
|
-
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (texts[0].trim().length === 0) {
|
|
376
|
+
date.startDate = null;
|
|
380
377
|
this.setState({
|
|
381
|
-
|
|
382
|
-
|
|
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.
|
|
401
|
-
}
|
|
409
|
+
var texts = this.state.texts;
|
|
402
410
|
|
|
403
|
-
|
|
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
|
|
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
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
-
|
|
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
|
-
|
|
447
|
+
_ref === 'input' ? texts[0] = e.target.value : texts[1] = e.target.value;
|
|
427
448
|
|
|
428
|
-
|
|
429
|
-
|
|
449
|
+
_this4.setState({
|
|
450
|
+
texts: texts
|
|
451
|
+
}, function () {
|
|
452
|
+
_this4.inputChangeEvent();
|
|
430
453
|
});
|
|
431
454
|
},
|
|
432
455
|
onFocus: function onFocus(e) {
|
|
433
|
-
|
|
456
|
+
_this4.setState({
|
|
434
457
|
showPanel: true,
|
|
435
458
|
isFocus: true
|
|
436
459
|
});
|
|
437
460
|
|
|
438
|
-
|
|
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
|
|
447
|
-
|
|
448
|
-
if (onChange) {
|
|
449
|
-
onChange(null);
|
|
450
|
-
}
|
|
469
|
+
var _this5 = this;
|
|
451
470
|
|
|
452
|
-
this.
|
|
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
|
|
463
|
-
|
|
464
|
-
|
|
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
|
-
}) :
|
|
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
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
|
492
|
-
className: _cls
|
|
493
|
-
|
|
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
|
|
499
|
-
|
|
500
|
-
|
|
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--
|
|
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
|
|
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
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}, type.indexOf('range') !== -1 || type === 'timeperiod' ? this.renderRangeInput() : this.renderNormalInput(), this.state.showPanel ?
|
|
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
|
-
|
|
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.
|
|
619
|
+
var _start = (0, _dateUtil.isValid)(val.start);
|
|
543
620
|
|
|
544
|
-
var _end = (0, _dateUtil.
|
|
621
|
+
var _end = (0, _dateUtil.isValid)(val.end);
|
|
545
622
|
|
|
546
|
-
if (_start
|
|
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.
|
|
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
|
-
|
|
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;
|