@hi-ui/hiui 2.15.10 → 2.15.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/es/_util/warning.js +2 -2
- package/es/alert/__test__/index.test.js +67 -0
- package/es/alert/index.js +147 -6
- package/es/alert/style/index.css +1 -1
- package/es/badge/index.js +87 -9
- package/es/badge/style/index.css +1 -1
- package/es/badge/style/index.js +0 -0
- package/es/button/Button.js +51 -59
- package/es/button/ButtonGroup.js +31 -23
- package/es/button/IconLoading.js +2 -2
- package/es/button/__test__/index.test.js +29 -0
- package/es/button/index.js +2 -3
- package/es/button/style/index.css +1 -1
- package/es/card/index.js +42 -54
- package/es/card/style/index.css +1 -1
- package/es/cascader/Cascader.js +116 -181
- package/es/cascader/__test__/index.test.js +283 -0
- package/es/cascader/index.js +2 -5
- package/es/cascader/menu.js +155 -0
- package/es/cascader/style/cascader.css +1 -1
- package/es/cascader/style/menu.css +1 -1
- package/es/checkbox/{checkbox-legacy/Base.js → Base.js} +31 -46
- package/es/checkbox/CheckBox.js +185 -0
- package/es/checkbox/index.js +4 -13
- package/es/checkbox/style/index.css +1 -1
- package/es/collapse/__test__/index.test.js +58 -0
- package/es/collapse/index.js +93 -79
- package/es/collapse/style/index.css +1 -1
- package/es/confirm/index.js +50 -37
- package/es/context/index.js +37 -39
- package/es/counter/__test__/index.test.js +52 -0
- package/es/counter/index.js +270 -6
- package/es/counter/style/index.css +1 -1
- package/es/date-picker/BasePicker.js +288 -374
- package/es/date-picker/Calender.js +90 -326
- package/es/date-picker/DatePanel.js +186 -175
- package/es/date-picker/DatePicker.js +51 -151
- package/es/date-picker/DateRangePanel.js +181 -253
- package/es/date-picker/Modal.js +25 -15
- package/es/date-picker/Time.js +336 -230
- package/es/date-picker/TimePanel.js +32 -27
- package/es/date-picker/TimePeriodPanel.js +32 -21
- package/es/date-picker/TimePicker.js +40 -42
- package/es/date-picker/TimeRangePanel.js +42 -32
- package/es/date-picker/Type.js +1 -5
- package/es/date-picker/WeekRangePanel.js +150 -237
- package/es/date-picker/constants.js +28 -14
- package/es/date-picker/dateUtil.js +52 -221
- package/es/date-picker/index.js +2 -5
- package/es/date-picker/style/index.css +1 -1
- package/es/date-picker/util.js +8 -101
- package/es/dropdown/Dropdown.js +199 -193
- package/es/dropdown/{tests → __test__}/index.test.js +2 -2
- package/es/dropdown/index.js +4 -73
- package/es/dropdown/style/index.css +1 -1
- package/es/dropdown/style/index.js +2 -0
- package/es/ficon/index.js +23 -13
- package/es/form/index.js +171 -6
- package/es/form/{Item.js → item.js} +53 -53
- package/es/form/style/index.css +1 -1
- package/es/grid/index.js +37 -25
- package/es/icon/index.js +32 -21
- package/es/index.js +9 -61
- package/es/input/index.js +345 -28
- package/es/input/style/index.css +1 -1
- package/es/input/util.js +18 -26
- package/es/lib/withDragDropContext.js +2 -2
- package/es/loading/index.js +129 -5
- package/es/loading/style/index.css +0 -0
- package/es/loading/style/index.js +0 -0
- package/es/locales/en-US.js +11 -45
- package/es/locales/index.js +2 -16
- package/es/locales/zh-CN.js +12 -46
- package/es/menu/Item.js +41 -32
- package/es/menu/ItemGroup.js +81 -0
- package/es/menu/SubMenu.js +74 -55
- package/es/menu/Title.js +42 -36
- package/es/menu/index.js +419 -12
- package/es/menu/style/index.css +1 -1
- package/es/modal/__test__/index.test.js +123 -0
- package/es/modal/index.js +61 -77
- package/es/modal/style/index.css +1 -1
- package/es/nav-menu/NavMenu.js +45 -31
- package/es/nav-menu/__test__/index.test.js +2 -2
- package/es/nav-menu/index.js +2 -2
- package/es/notification/__test__/index.test.js +56 -0
- package/es/notification/index.js +231 -68
- package/es/notification/style/index.css +1 -1
- package/es/notification/style/index.js +0 -0
- package/es/pagination/Pager.js +8 -6
- package/es/pagination/Pagination.js +115 -124
- package/es/pagination/__test__/index.test.js +140 -0
- package/es/pagination/index.js +8 -9
- package/es/pagination/style/index.css +1 -1
- package/es/panel/index.js +33 -23
- package/es/popover/__test__/index.test.js +2 -2
- package/es/popover/index.js +69 -71
- package/es/popper/index.js +54 -64
- package/es/popper/style/index.css +1 -1
- package/es/progress/BarProgress.js +43 -109
- package/es/progress/CircleProgress.js +10 -9
- package/es/progress/DashboardProgress.js +9 -7
- package/es/progress/index.js +100 -8
- package/es/progress/style/index.css +1 -1
- package/es/radio/{radio-legacy/__test__ → __test__}/index.test.js +10 -10
- package/es/radio/index.js +216 -10
- package/es/radio/style/index.css +1 -1
- package/es/rate/Icons.js +2 -2
- package/es/rate/Rate.js +90 -65
- package/es/rate/__test__/index.test.js +54 -0
- package/es/rate/index.js +2 -5
- package/es/rate/style/index.css +1 -1
- package/es/select/Option.js +93 -0
- package/es/select/Select.js +253 -325
- package/es/select/SelectDropdown.js +63 -215
- package/es/select/SelectInput.js +54 -88
- package/es/select/__test__/index.test.js +429 -0
- package/es/select/index.js +4 -6
- package/es/select/style/select-dropdown.css +1 -1
- package/es/select/style/select-input.css +1 -1
- package/es/stepper/index.js +127 -21
- package/es/stepper/style/index.css +1 -1
- package/es/style/color/colors.css +0 -0
- package/es/style/icon/diyIcon.css +1 -1
- package/es/style/icon/index.css +1 -1
- 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/{__tests__ → __test__}/index.test.js +2 -31
- package/es/switch/index.js +36 -24
- package/es/switch/style/index.css +1 -1
- package/es/table/__test__/index.test.js +73 -0
- package/es/table/{Body.js → body.js} +52 -36
- package/es/table/checkbox/index.js +36 -33
- package/es/table/clickOuterside.js +115 -0
- package/es/table/{Footer.js → footer.js} +41 -24
- package/es/table/{Header.js → header.js} +54 -41
- package/es/table/index.js +300 -262
- package/es/table/menu/index.js +34 -32
- package/es/table/pover.js +154 -0
- 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/table/tableContent.js +120 -0
- package/es/tabs/ItemDropdown.js +51 -39
- package/es/tabs/TabPane.js +35 -25
- package/es/tabs/Tabs.js +91 -98
- package/es/tabs/index.js +3 -9
- package/es/tabs/style/index.css +1 -1
- package/es/timeline/__test__/index.test.js +49 -0
- package/es/timeline/foldingItem.js +82 -0
- package/es/timeline/index.js +127 -203
- package/es/timeline/style/index.css +1 -1
- package/es/tooltip/__test__/index.test.js +67 -0
- package/es/tooltip/index.js +39 -86
- package/es/tooltip/style/index.css +1 -1
- package/es/transfer/Item.js +44 -53
- package/es/transfer/__test__/index.test.js +11 -0
- package/es/transfer/index.js +443 -4
- package/es/transfer/style/index.css +1 -1
- package/es/tree/Tree.js +86 -76
- package/es/tree/TreeDivider.js +3 -3
- package/es/tree/TreeItem.js +108 -204
- package/es/tree/TreeNode.js +318 -457
- package/es/tree/index.js +2 -9
- package/es/tree/style/index.css +1 -1
- package/es/tree/util.js +257 -9
- package/es/upload/{upload-legacy/Preview.js → Preview.js} +39 -33
- package/es/upload/Upload.js +193 -289
- package/es/upload/UploadAvatar.js +58 -44
- package/es/upload/UploadClick.js +45 -49
- package/es/upload/UploadDrag.js +43 -44
- package/es/upload/UploadPhoto.js +55 -70
- package/es/upload/UploadPictureCard.js +44 -39
- package/es/upload/index.js +71 -8
- package/es/upload/style/index.css +1 -1
- package/es/upload/tool.js +1 -0
- package/package.json +4 -1
- package/es/_util/SwitchVersion.js +0 -44
- package/es/_util/depreactedPropsCompat.js +0 -58
- package/es/_util/index.js +0 -32
- package/es/alert/Alert.js +0 -134
- package/es/alert/__tests__/index.test.js +0 -88
- package/es/badge/Badge.js +0 -90
- package/es/badge/__tests__/index.test.js +0 -82
- package/es/breadcrumb/__tests__/index.test.js +0 -61
- package/es/breadcrumb/index.js +0 -93
- package/es/breadcrumb/style/index.css +0 -1
- package/es/button/__tests__/index.test.js +0 -219
- package/es/card/__tests__/index.test.js +0 -169
- package/es/carousel/__tests__/index.test.js +0 -104
- package/es/carousel/index.js +0 -227
- package/es/carousel/style/index.css +0 -1
- package/es/carousel/style/index.js +0 -3
- package/es/cascader/Menu.js +0 -174
- package/es/cascader/__tests__/index.test.js +0 -389
- package/es/checkbox/Checkbox.js +0 -144
- package/es/checkbox/Group.js +0 -202
- package/es/checkbox/__tests__/index.test.js +0 -226
- package/es/checkbox/checkbox-legacy/CheckBox.js +0 -165
- package/es/checkbox/checkbox-legacy/index.js +0 -15
- package/es/checkbox/checkbox-legacy/style/index.css +0 -1
- package/es/checkbox/checkbox-legacy/style/index.js +0 -3
- package/es/collapse/__tests__/index.test.js +0 -111
- package/es/counter/Counter.js +0 -343
- package/es/counter/__tests__/index.test.js +0 -134
- package/es/counter/counter-legacy/index.js +0 -271
- package/es/date-picker/TimeList.js +0 -254
- package/es/date-picker/YMRangePanel.js +0 -372
- package/es/date-picker/__tests__/index.test.js +0 -961
- package/es/date-picker/datepicker-legacy/BasePicker.js +0 -519
- package/es/date-picker/datepicker-legacy/Calender.js +0 -430
- package/es/date-picker/datepicker-legacy/DatePanel.js +0 -463
- package/es/date-picker/datepicker-legacy/DatePicker.js +0 -107
- package/es/date-picker/datepicker-legacy/DateRangePanel.js +0 -496
- package/es/date-picker/datepicker-legacy/Modal.js +0 -71
- package/es/date-picker/datepicker-legacy/Time.js +0 -413
- package/es/date-picker/datepicker-legacy/TimePanel.js +0 -93
- package/es/date-picker/datepicker-legacy/TimePeriodPanel.js +0 -126
- package/es/date-picker/datepicker-legacy/TimePicker.js +0 -82
- package/es/date-picker/datepicker-legacy/TimeRangePanel.js +0 -98
- package/es/date-picker/datepicker-legacy/Type.js +0 -31
- package/es/date-picker/datepicker-legacy/WeekRangePanel.js +0 -345
- package/es/date-picker/datepicker-legacy/constants.js +0 -79
- package/es/date-picker/datepicker-legacy/dateUtil.js +0 -258
- package/es/date-picker/datepicker-legacy/index.js +0 -15
- package/es/date-picker/datepicker-legacy/local.js +0 -11
- package/es/date-picker/datepicker-legacy/style/index.css +0 -1
- package/es/date-picker/datepicker-legacy/style/index.js +0 -3
- package/es/date-picker/datepicker-legacy/style/timepicker.css +0 -1
- package/es/date-picker/datepicker-legacy/util.js +0 -60
- package/es/date-picker/toLunar.js +0 -172
- package/es/dropdown/DropdownButton.js +0 -106
- package/es/dropdown/DropdownMenu.js +0 -111
- package/es/dropdown/DropdownMenuItem.js +0 -178
- package/es/dropdown/__tests__/index.test.js +0 -317
- package/es/dropdown/utils.js +0 -35
- package/es/form/Form.js +0 -184
- package/es/form/__tests__/index.test.js +0 -575
- package/es/grid/__tests__/index.test.js +0 -104
- package/es/input/Input.js +0 -412
- package/es/input/__tests__/index.test.js +0 -381
- package/es/input/input-legacy/index.js +0 -353
- package/es/input/input-legacy/util.js +0 -176
- package/es/loading/Loading.js +0 -181
- package/es/loading/__tests__/index.test.js +0 -110
- package/es/locales/zh-Hant-HK.js +0 -121
- package/es/locales/zh-Hant-TW.js +0 -123
- package/es/menu/Menu.js +0 -422
- package/es/menu/__tests__/index.test.js +0 -279
- package/es/message/__tests__/index.test.js +0 -75
- package/es/message/index.js +0 -58
- package/es/message/style/index.css +0 -1
- package/es/message/style/index.js +0 -5
- package/es/modal/__tests__/index.test.js +0 -178
- package/es/nav-menu/__tests__/index.test.js +0 -27
- package/es/notice/Notice.js +0 -142
- package/es/notice/NoticeContainer.js +0 -113
- package/es/notice/__tests__/index.test.js +0 -174
- package/es/notice/index.js +0 -66
- package/es/notice/style/index.css +0 -1
- package/es/notice/style/index.js +0 -5
- package/es/notification/HandleNotification/index.js +0 -224
- package/es/notification/HandleNotification/style/index.css +0 -1
- package/es/notification/HandleNotification/style/index.js +0 -5
- package/es/notification/__tests__/index.test.js +0 -118
- package/es/pagination/__tests__/index.test.js +0 -248
- package/es/popover/__tests__/index.test.js +0 -152
- package/es/preview/index.js +0 -527
- package/es/preview/style/index.css +0 -1
- package/es/preview/style/index.js +0 -3
- package/es/progress/Progress.js +0 -110
- package/es/progress/__tests__/index.test.js +0 -131
- package/es/radio/Group.js +0 -203
- package/es/radio/Radio.js +0 -151
- package/es/radio/__tests__/index.test.js +0 -128
- package/es/radio/radio-legacy/index.js +0 -222
- package/es/radio/radio-legacy/style/index.css +0 -1
- package/es/radio/radio-legacy/style/index.js +0 -3
- package/es/rate/__tests__/index.test.js +0 -124
- package/es/select/__tests__/index.test.js +0 -505
- package/es/select/select-legacy/Option.js +0 -81
- package/es/select/select-legacy/Select.js +0 -710
- package/es/select/select-legacy/SelectDropdown.js +0 -164
- package/es/select/select-legacy/SelectInput.js +0 -312
- package/es/select/select-legacy/common.js +0 -19
- package/es/select/select-legacy/index.js +0 -16
- package/es/stepper/Stepper.js +0 -151
- package/es/stepper/__tests__/index.test.js +0 -161
- package/es/table/ClickOuterside.js +0 -103
- package/es/table/TableContent.js +0 -109
- package/es/table/__tests__/index.test.js +0 -133
- package/es/table/checkbox/style/index.css +0 -1
- package/es/table/checkbox/style/index.js +0 -3
- package/es/tabs/__tests__/index.test.js +0 -333
- package/es/tabs/tabs-legacy/ItemDropdown.js +0 -170
- package/es/tabs/tabs-legacy/TabPane.js +0 -78
- package/es/tabs/tabs-legacy/Tabs.js +0 -299
- package/es/tabs/tabs-legacy/index.js +0 -18
- package/es/tabs/tabs-legacy/style/index.css +0 -1
- package/es/tabs/tabs-legacy/style/index.js +0 -3
- package/es/tag/__tests__/index.test.js +0 -46
- package/es/tag/index.js +0 -94
- package/es/tag/style/index.css +0 -1
- package/es/tag/style/index.js +0 -3
- package/es/timeline/__tests__/index.test.js +0 -198
- package/es/tooltip/__tests__/index.test.js +0 -170
- package/es/transfer/Transfer.js +0 -566
- package/es/transfer/__tests__/index.test.js +0 -210
- package/es/tree/IconLoading.js +0 -38
- package/es/tree/__tests__/index.test.js +0 -603
- package/es/tree/tree-legacy/Tree.js +0 -337
- package/es/tree/tree-legacy/TreeDivider.js +0 -25
- package/es/tree/tree-legacy/TreeItem.js +0 -333
- package/es/tree/tree-legacy/TreeNode.js +0 -719
- package/es/tree/tree-legacy/index.js +0 -13
- package/es/tree/tree-legacy/style/index.css +0 -1
- package/es/tree/tree-legacy/style/index.js +0 -3
- package/es/tree/tree-legacy/util.js +0 -434
- package/es/upload/__tests__/index.test.js +0 -760
- package/es/upload/main.js +0 -91
- package/es/upload/upload-legacy/Upload.js +0 -435
- package/es/upload/upload-legacy/UploadAvatar.js +0 -322
- package/es/upload/upload-legacy/UploadClick.js +0 -125
- package/es/upload/upload-legacy/UploadDrag.js +0 -180
- package/es/upload/upload-legacy/UploadPhoto.js +0 -183
- package/es/upload/upload-legacy/UploadPictureCard.js +0 -126
- package/es/upload/upload-legacy/index.js +0 -75
- package/es/upload/upload-legacy/style/index.css +0 -1
- package/es/upload/upload-legacy/style/index.js +0 -5
- package/es/upload/upload-legacy/tool.js +0 -84
- package/es/watermark/index.js +0 -101
- package/es/watermark/watermark.js +0 -252
- /package/es/checkbox/{checkbox-legacy/common.js → common.js} +0 -0
- /package/es/{breadcrumb/style → style}/index.js +0 -0
- /package/es/upload/{upload-legacy/style → style}/preview.css +0 -0
- /package/es/upload/{upload-legacy/style → style}/preview.js +0 -0
package/es/confirm/index.js
CHANGED
|
@@ -1,66 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
6
|
exports["default"] = getConfirmInstance;
|
|
11
7
|
|
|
12
|
-
var
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
9
|
|
|
14
|
-
var
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
11
|
|
|
16
|
-
var
|
|
12
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
17
13
|
|
|
18
|
-
var
|
|
14
|
+
var _modal = _interopRequireDefault(require("../modal"));
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
require("./style/index");
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
25
21
|
|
|
26
|
-
var
|
|
22
|
+
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; }
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
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); }
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
27
|
|
|
32
|
-
function
|
|
28
|
+
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); } }
|
|
33
29
|
|
|
34
|
-
function
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
35
31
|
|
|
36
|
-
function
|
|
32
|
+
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); }
|
|
37
33
|
|
|
38
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
+
|
|
36
|
+
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); }; }
|
|
37
|
+
|
|
38
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
39
|
+
|
|
40
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
+
|
|
42
|
+
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; } }
|
|
43
|
+
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
45
|
|
|
40
46
|
var Confirm = /*#__PURE__*/function (_Component) {
|
|
41
|
-
(
|
|
47
|
+
_inherits(Confirm, _Component);
|
|
42
48
|
|
|
43
49
|
var _super = _createSuper(Confirm);
|
|
44
50
|
|
|
45
51
|
function Confirm() {
|
|
46
|
-
(
|
|
52
|
+
_classCallCheck(this, Confirm);
|
|
53
|
+
|
|
47
54
|
return _super.apply(this, arguments);
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
(
|
|
57
|
+
_createClass(Confirm, [{
|
|
51
58
|
key: "render",
|
|
52
59
|
value: function render() {
|
|
53
60
|
var _this$props = this.props,
|
|
54
|
-
|
|
61
|
+
tip = _this$props.tip,
|
|
55
62
|
onOk = _this$props.onOk,
|
|
56
|
-
_onCancel = _this$props.onCancel
|
|
57
|
-
title = _this$props.title,
|
|
58
|
-
localeDatas = _this$props.localeDatas;
|
|
63
|
+
_onCancel = _this$props.onCancel;
|
|
59
64
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
60
65
|
className: "hi-confirm"
|
|
61
66
|
}, /*#__PURE__*/_react["default"].createElement(_modal["default"], {
|
|
62
|
-
|
|
63
|
-
title: title,
|
|
67
|
+
title: "",
|
|
64
68
|
ref: "hi-confirm",
|
|
65
69
|
show: true,
|
|
66
70
|
size: "small",
|
|
@@ -71,33 +75,42 @@ var Confirm = /*#__PURE__*/function (_Component) {
|
|
|
71
75
|
confirmType: "default",
|
|
72
76
|
cancelType: "danger",
|
|
73
77
|
onConfirm: function onConfirm() {
|
|
74
|
-
|
|
78
|
+
return function () {
|
|
75
79
|
onOk();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
confirmInstance.destroy();
|
|
80
|
+
confirmInstance.destroy();
|
|
81
|
+
}();
|
|
79
82
|
},
|
|
80
83
|
onCancel: function onCancel() {
|
|
81
|
-
|
|
84
|
+
return function () {
|
|
82
85
|
_onCancel();
|
|
83
|
-
}
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
confirmInstance.destroy();
|
|
88
|
+
}();
|
|
86
89
|
}
|
|
87
|
-
},
|
|
90
|
+
}, tip));
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "componentDidMount",
|
|
94
|
+
value: function componentDidMount() {
|
|
95
|
+
_modal["default"].show.call(this, 'hi-confirm');
|
|
88
96
|
}
|
|
89
97
|
}]);
|
|
98
|
+
|
|
90
99
|
return Confirm;
|
|
91
100
|
}(_react.Component);
|
|
92
101
|
|
|
93
|
-
Confirm.
|
|
102
|
+
Confirm.propTypes = {
|
|
103
|
+
tip: _propTypes["default"].string,
|
|
104
|
+
onOk: _propTypes["default"]["function"],
|
|
105
|
+
onCancel: _propTypes["default"]["function"]
|
|
106
|
+
};
|
|
94
107
|
|
|
95
108
|
Confirm.newInstance = function newNotificationInstance(properties) {
|
|
96
109
|
var props = properties || {};
|
|
97
110
|
var div = document.createElement('div');
|
|
98
111
|
document.body.appendChild(div);
|
|
99
112
|
|
|
100
|
-
_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(
|
|
113
|
+
_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(Confirm, props), div);
|
|
101
114
|
|
|
102
115
|
return {
|
|
103
116
|
destroy: function destroy() {
|
package/es/context/index.js
CHANGED
|
@@ -1,86 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
6
|
exports["default"] = exports.LocaleContext = exports.ThemeContext = void 0;
|
|
11
7
|
|
|
12
|
-
var
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
9
|
|
|
14
|
-
var
|
|
10
|
+
var _locales = _interopRequireDefault(require("../locales"));
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
19
15
|
|
|
20
|
-
var
|
|
16
|
+
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; }
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
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); }
|
|
23
19
|
|
|
24
|
-
var
|
|
20
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
21
|
|
|
26
|
-
var
|
|
22
|
+
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; }
|
|
27
23
|
|
|
28
|
-
var
|
|
24
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
+
|
|
28
|
+
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); } }
|
|
31
29
|
|
|
32
|
-
function
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
33
31
|
|
|
34
|
-
function
|
|
32
|
+
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); }
|
|
35
33
|
|
|
36
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
35
|
|
|
38
|
-
function
|
|
36
|
+
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); }; }
|
|
37
|
+
|
|
38
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
39
|
+
|
|
40
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
+
|
|
42
|
+
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; } }
|
|
43
|
+
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
45
|
|
|
40
46
|
var ThemeContext = /*#__PURE__*/_react["default"].createContext('hiui-blue');
|
|
41
47
|
|
|
42
48
|
exports.ThemeContext = ThemeContext;
|
|
43
49
|
|
|
44
|
-
var LocaleContext = /*#__PURE__*/_react["default"].createContext('zh-
|
|
45
|
-
/**
|
|
46
|
-
* 临时解决 notice组件获取不到theme的问题
|
|
47
|
-
*/
|
|
48
|
-
|
|
50
|
+
var LocaleContext = /*#__PURE__*/_react["default"].createContext('zh-CN');
|
|
49
51
|
|
|
50
52
|
exports.LocaleContext = LocaleContext;
|
|
51
|
-
var noticeTheme = '';
|
|
52
|
-
var confirmLocale = '';
|
|
53
53
|
|
|
54
54
|
var _default = function _default(WrappedComponent) {
|
|
55
55
|
var WrapperComponent = /*#__PURE__*/function (_Component) {
|
|
56
|
-
(
|
|
56
|
+
_inherits(WrapperComponent, _Component);
|
|
57
57
|
|
|
58
58
|
var _super = _createSuper(WrapperComponent);
|
|
59
59
|
|
|
60
60
|
function WrapperComponent() {
|
|
61
|
-
(
|
|
61
|
+
_classCallCheck(this, WrapperComponent);
|
|
62
|
+
|
|
62
63
|
return _super.apply(this, arguments);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
(
|
|
66
|
+
_createClass(WrapperComponent, [{
|
|
66
67
|
key: "render",
|
|
67
68
|
value: function render() {
|
|
68
69
|
var _this$props = this.props,
|
|
69
70
|
theme = _this$props.theme,
|
|
70
71
|
locale = _this$props.locale,
|
|
71
72
|
innerRef = _this$props.innerRef,
|
|
72
|
-
restProps = (
|
|
73
|
+
restProps = _objectWithoutProperties(_this$props, ["theme", "locale", "innerRef"]);
|
|
73
74
|
|
|
74
75
|
var ConsumerComponent = /*#__PURE__*/_react["default"].createElement(ThemeContext.Consumer, null, function (contextTheme) {
|
|
75
|
-
noticeTheme = noticeTheme || contextTheme;
|
|
76
76
|
return /*#__PURE__*/_react["default"].createElement(LocaleContext.Consumer, null, function (contextLocale) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
ref: innerRef,
|
|
83
|
-
innerRef: innerRef
|
|
77
|
+
return /*#__PURE__*/_react["default"].createElement(WrappedComponent, _extends({
|
|
78
|
+
theme: contextTheme,
|
|
79
|
+
locale: contextLocale,
|
|
80
|
+
localeDatas: _locales["default"][contextLocale],
|
|
81
|
+
ref: innerRef
|
|
84
82
|
}, restProps));
|
|
85
83
|
});
|
|
86
84
|
});
|
|
@@ -88,12 +86,12 @@ var _default = function _default(WrappedComponent) {
|
|
|
88
86
|
return wrapProvider(theme, ThemeContext)(locale, LocaleContext)(ConsumerComponent);
|
|
89
87
|
}
|
|
90
88
|
}]);
|
|
89
|
+
|
|
91
90
|
return WrapperComponent;
|
|
92
91
|
}(_react.Component);
|
|
93
92
|
|
|
94
|
-
(0, _defineProperty2["default"])(WrapperComponent, "displayName", WrappedComponent.name);
|
|
95
93
|
return /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
96
|
-
return /*#__PURE__*/_react["default"].createElement(WrapperComponent, (
|
|
94
|
+
return /*#__PURE__*/_react["default"].createElement(WrapperComponent, _extends({}, props, {
|
|
97
95
|
innerRef: ref
|
|
98
96
|
}));
|
|
99
97
|
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
|
+
var _enzyme = require("enzyme");
|
|
6
|
+
|
|
7
|
+
var _ = _interopRequireDefault(require("../"));
|
|
8
|
+
|
|
9
|
+
var _module = require("module");
|
|
10
|
+
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
|
|
13
|
+
var changeCallback = jest.fn(function (val) {
|
|
14
|
+
return val;
|
|
15
|
+
});
|
|
16
|
+
describe('Counter', function () {
|
|
17
|
+
it('基础操作', function () {
|
|
18
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
|
|
19
|
+
value: "4",
|
|
20
|
+
step: "1",
|
|
21
|
+
min: "-10",
|
|
22
|
+
max: "10",
|
|
23
|
+
onChange: changeCallback
|
|
24
|
+
}));
|
|
25
|
+
expect(wrapper.find('input').props().value).toEqual('4');
|
|
26
|
+
wrapper.find('.hi-counter-plus').simulate('click'); // +1
|
|
27
|
+
|
|
28
|
+
expect(wrapper.find('input').props().value).toEqual('5');
|
|
29
|
+
wrapper.find('.hi-counter-minus').simulate('click'); // -1
|
|
30
|
+
|
|
31
|
+
expect(wrapper.find('input').props().value).toEqual('4');
|
|
32
|
+
wrapper.find('input').simulate('change', {
|
|
33
|
+
target: {
|
|
34
|
+
value: '100'
|
|
35
|
+
}
|
|
36
|
+
}); // 测试超过最大值
|
|
37
|
+
|
|
38
|
+
wrapper.find('input').simulate('blur');
|
|
39
|
+
expect(wrapper.find('input').props().value).toEqual('10');
|
|
40
|
+
expect(wrapper.find('.hi-counter-plus').hasClass('disabled')).toEqual(true); // 已达到最大值时+不可点击
|
|
41
|
+
|
|
42
|
+
wrapper.find('input').simulate('change', {
|
|
43
|
+
target: {
|
|
44
|
+
value: '-100'
|
|
45
|
+
}
|
|
46
|
+
}); // 测试超过最小值
|
|
47
|
+
|
|
48
|
+
wrapper.find('input').simulate('blur');
|
|
49
|
+
expect(wrapper.find('input').props().value).toEqual('-10');
|
|
50
|
+
expect(wrapper.find('.hi-counter-minus').hasClass('disabled')).toEqual(true); // 已达到最小值时-不可点击
|
|
51
|
+
});
|
|
52
|
+
});
|
package/es/counter/index.js
CHANGED
|
@@ -1,20 +1,284 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports["default"] = void 0;
|
|
9
7
|
|
|
10
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
12
|
require("./style/index");
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
+
|
|
22
|
+
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); } }
|
|
23
|
+
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
25
|
+
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
+
|
|
30
|
+
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); }; }
|
|
31
|
+
|
|
32
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
+
|
|
34
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
+
|
|
36
|
+
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; } }
|
|
37
|
+
|
|
38
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 加减器
|
|
44
|
+
*/
|
|
45
|
+
var Counter = /*#__PURE__*/function (_React$Component) {
|
|
46
|
+
_inherits(Counter, _React$Component);
|
|
47
|
+
|
|
48
|
+
var _super = _createSuper(Counter);
|
|
49
|
+
|
|
50
|
+
function Counter(props) {
|
|
51
|
+
var _this;
|
|
52
|
+
|
|
53
|
+
_classCallCheck(this, Counter);
|
|
54
|
+
|
|
55
|
+
_this = _super.call(this, props);
|
|
56
|
+
var oldProps = Object.assign({}, _this.props);
|
|
57
|
+
_this.attrs = _this.getAttrs(oldProps);
|
|
58
|
+
var _this$props = _this.props,
|
|
59
|
+
value = _this$props.value,
|
|
60
|
+
min = _this$props.min,
|
|
61
|
+
max = _this$props.max;
|
|
62
|
+
var finalValue = Math.min(Math.max(Number(value), Number(min)), Number(max));
|
|
63
|
+
_this.state = {
|
|
64
|
+
value: _this.format(finalValue),
|
|
65
|
+
valueTrue: _this.formatValue(finalValue)
|
|
66
|
+
};
|
|
67
|
+
return _this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_createClass(Counter, [{
|
|
71
|
+
key: "componentWillReceiveProps",
|
|
72
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
73
|
+
if (nextProps.value && +nextProps.value !== +this.props.value) {
|
|
74
|
+
this.setState({
|
|
75
|
+
value: this.format(nextProps.value),
|
|
76
|
+
valueTrue: this.formatValue(nextProps.value)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 提取非函数属性
|
|
82
|
+
* @param {object} oldProps 原始props
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
}, {
|
|
86
|
+
key: "getAttrs",
|
|
87
|
+
value: function getAttrs(oldProps) {
|
|
88
|
+
var attrs = {};
|
|
89
|
+
var noNeed = ['value', 'className', 'class', 'id', 'style', 'type', 'placeholder', 'disabled'];
|
|
90
|
+
|
|
91
|
+
for (var i in oldProps) {
|
|
92
|
+
if (!(oldProps[i] instanceof Function)) {
|
|
93
|
+
if (noNeed.indexOf(i) === -1) {
|
|
94
|
+
attrs[i] = oldProps[i];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return attrs;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 净化数据
|
|
103
|
+
* @param {string} val 值
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
}, {
|
|
107
|
+
key: "formatValue",
|
|
108
|
+
value: function formatValue(value) {
|
|
109
|
+
var type = _typeof(value);
|
|
15
110
|
|
|
16
|
-
|
|
111
|
+
if (type !== 'string' && type !== 'number') {
|
|
112
|
+
value = '';
|
|
113
|
+
}
|
|
17
114
|
|
|
18
|
-
|
|
115
|
+
return isNaN(Number(value)) ? value.toString().replace(/[^-\d]/g, '') : value;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 格式化数据
|
|
119
|
+
* 88,888
|
|
120
|
+
* @param {string} val 值
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
}, {
|
|
124
|
+
key: "format",
|
|
125
|
+
value: function format(val) {
|
|
126
|
+
return val && (val.toString().indexOf('.') !== -1 ? val.toString().replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {
|
|
127
|
+
return $1 + ',';
|
|
128
|
+
}) : val.toString().replace(/(\d)(?=(\d{3}))/g, function ($0, $1) {
|
|
129
|
+
return $1 + ',';
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* minus plus 事件
|
|
134
|
+
* @param {string} minus 类型
|
|
135
|
+
* @param {string} plus 类型
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
}, {
|
|
139
|
+
key: "signEvent",
|
|
140
|
+
value: function signEvent(type, disabled) {
|
|
141
|
+
var _this2 = this;
|
|
142
|
+
|
|
143
|
+
var min = +this.props.min;
|
|
144
|
+
var max = +this.props.max;
|
|
145
|
+
var step = +this.props.step;
|
|
146
|
+
|
|
147
|
+
if (disabled) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var valueTrue = +this.state.valueTrue;
|
|
152
|
+
var steps = +step;
|
|
153
|
+
|
|
154
|
+
switch (type) {
|
|
155
|
+
case 'minus':
|
|
156
|
+
valueTrue -= steps;
|
|
157
|
+
|
|
158
|
+
if (valueTrue < min) {
|
|
159
|
+
valueTrue = min;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
case 'plus':
|
|
165
|
+
valueTrue += steps;
|
|
166
|
+
|
|
167
|
+
if (valueTrue > max) {
|
|
168
|
+
valueTrue = max;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
break;
|
|
172
|
+
|
|
173
|
+
default:
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var value = this.format(valueTrue + '');
|
|
177
|
+
this.setState({
|
|
178
|
+
value: value,
|
|
179
|
+
valueTrue: valueTrue
|
|
180
|
+
}, function () {
|
|
181
|
+
var e = {
|
|
182
|
+
target: _this2._Input
|
|
183
|
+
};
|
|
184
|
+
_this2.props.onChange && _this2.props.onChange(e, valueTrue);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}, {
|
|
188
|
+
key: "render",
|
|
189
|
+
value: function render() {
|
|
190
|
+
var _this3 = this;
|
|
191
|
+
|
|
192
|
+
var _this$props2 = this.props,
|
|
193
|
+
className = _this$props2.className,
|
|
194
|
+
id = _this$props2.id,
|
|
195
|
+
disabled = _this$props2.disabled;
|
|
196
|
+
var min = +this.props.min;
|
|
197
|
+
var max = +this.props.max;
|
|
198
|
+
var _this$state = this.state,
|
|
199
|
+
value = _this$state.value,
|
|
200
|
+
valueTrue = _this$state.valueTrue;
|
|
201
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
202
|
+
className: "hi-counter ".concat(className || ''),
|
|
203
|
+
id: id
|
|
204
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
205
|
+
className: "hi-counter-outer"
|
|
206
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
207
|
+
className: "hi-counter-minus hi-counter-sign ".concat(min !== undefined && this.state.valueTrue <= min || disabled ? 'disabled' : ''),
|
|
208
|
+
onClick: function onClick(e) {
|
|
209
|
+
_this3.signEvent('minus', min !== undefined && _this3.state.valueTrue <= min || disabled);
|
|
210
|
+
}
|
|
211
|
+
}, "-"), /*#__PURE__*/_react["default"].createElement("input", _extends({
|
|
212
|
+
id: id ? "".concat(id, "_value") : '',
|
|
213
|
+
ref: function ref(arg) {
|
|
214
|
+
_this3._Input = arg;
|
|
215
|
+
},
|
|
216
|
+
value: this.state.value,
|
|
217
|
+
disabled: disabled,
|
|
218
|
+
"data-value": this.state.valueTrue
|
|
219
|
+
}, this.attrs, {
|
|
220
|
+
onChange: function onChange(e) {
|
|
221
|
+
e.persist();
|
|
222
|
+
var value = e.target.value;
|
|
223
|
+
value = _this3.format(value);
|
|
224
|
+
|
|
225
|
+
var valueTrue = _this3.formatValue(value);
|
|
226
|
+
|
|
227
|
+
_this3.setState({
|
|
228
|
+
value: value,
|
|
229
|
+
valueTrue: valueTrue
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
onBlur: function onBlur(e) {
|
|
233
|
+
e.persist();
|
|
234
|
+
|
|
235
|
+
if (typeof min !== 'undefined' && +valueTrue < min) {
|
|
236
|
+
value = _this3.format(min);
|
|
237
|
+
valueTrue = min;
|
|
238
|
+
} else if (typeof max !== 'undefined' && +valueTrue > max) {
|
|
239
|
+
value = _this3.format(max);
|
|
240
|
+
valueTrue = max;
|
|
241
|
+
} else {
|
|
242
|
+
value = _this3.format(valueTrue);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
_this3.setState({
|
|
246
|
+
value: value,
|
|
247
|
+
valueTrue: valueTrue
|
|
248
|
+
}, function () {
|
|
249
|
+
_this3.props.onChange && _this3.props.onChange(e, valueTrue);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
})), /*#__PURE__*/_react["default"].createElement("span", {
|
|
253
|
+
className: "hi-counter-plus hi-counter-sign ".concat(max !== undefined && this.state.valueTrue >= max || disabled ? 'disabled' : ''),
|
|
254
|
+
onClick: function onClick(e) {
|
|
255
|
+
_this3.signEvent('plus', max !== undefined && _this3.state.valueTrue >= max || disabled);
|
|
256
|
+
}
|
|
257
|
+
}, "+")));
|
|
258
|
+
}
|
|
259
|
+
}]);
|
|
260
|
+
|
|
261
|
+
return Counter;
|
|
262
|
+
}(_react["default"].Component);
|
|
263
|
+
|
|
264
|
+
_defineProperty(Counter, "_Input", '');
|
|
265
|
+
|
|
266
|
+
_defineProperty(Counter, "propTypes", {
|
|
267
|
+
value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
268
|
+
step: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
269
|
+
min: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
270
|
+
max: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
271
|
+
onChange: _propTypes["default"].func
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
_defineProperty(Counter, "defaultProps", {
|
|
275
|
+
// prefixCls: 'hi-collapse',
|
|
276
|
+
// activeIndex: 1
|
|
277
|
+
value: 0,
|
|
278
|
+
step: 1 // max: null,
|
|
279
|
+
// min: null
|
|
280
|
+
|
|
281
|
+
});
|
|
19
282
|
|
|
283
|
+
var _default = Counter;
|
|
20
284
|
exports["default"] = _default;
|