@hi-ui/hiui 2.15.11 → 2.15.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/_util/SwitchVersion.js +40 -0
- package/es/_util/depreactedPropsCompat.js +58 -0
- package/es/_util/index.js +31 -0
- package/es/_util/warning.js +2 -2
- package/es/alert/Alert.js +126 -0
- package/es/alert/__tests__/index.test.js +84 -0
- package/es/alert/index.js +6 -147
- package/es/alert/style/index.css +1 -1
- package/es/badge/Badge.js +82 -0
- package/es/badge/__tests__/index.test.js +82 -0
- package/es/badge/index.js +9 -87
- package/es/badge/style/index.css +1 -1
- package/es/badge/style/index.js +0 -0
- package/es/breadcrumb/__tests__/index.test.js +61 -0
- package/es/breadcrumb/index.js +85 -0
- package/es/breadcrumb/style/index.css +1 -0
- package/es/button/Button.js +62 -60
- package/es/button/ButtonGroup.js +24 -40
- package/es/button/IconLoading.js +6 -6
- package/es/button/__tests__/index.test.js +221 -0
- package/es/button/index.js +3 -2
- package/es/button/style/index.css +1 -1
- package/es/card/__tests__/index.test.js +179 -0
- package/es/card/index.js +61 -57
- package/es/card/style/index.css +1 -1
- package/es/carousel/__tests__/index.test.js +104 -0
- package/es/carousel/index.js +219 -0
- package/es/carousel/style/index.css +1 -0
- package/es/carousel/style/index.js +3 -0
- package/es/cascader/Cascader.js +190 -133
- package/es/cascader/Menu.js +168 -0
- package/es/cascader/__tests__/index.test.js +392 -0
- package/es/cascader/index.js +5 -2
- package/es/cascader/style/cascader.css +1 -1
- package/es/cascader/style/menu.css +1 -1
- package/es/checkbox/Checkbox.js +136 -0
- package/es/checkbox/Group.js +194 -0
- package/es/checkbox/__tests__/index.test.js +226 -0
- package/es/checkbox/checkbox-legacy/Base.js +212 -0
- package/es/checkbox/checkbox-legacy/CheckBox.js +157 -0
- package/es/checkbox/checkbox-legacy/index.js +15 -0
- package/es/checkbox/checkbox-legacy/style/index.css +1 -0
- package/es/checkbox/checkbox-legacy/style/index.js +3 -0
- package/es/checkbox/index.js +13 -4
- package/es/checkbox/style/index.css +1 -1
- package/es/collapse/__tests__/index.test.js +111 -0
- package/es/collapse/index.js +88 -110
- package/es/collapse/style/index.css +1 -1
- package/es/confirm/index.js +39 -60
- package/es/context/index.js +45 -51
- package/es/counter/Counter.js +339 -0
- package/es/counter/__tests__/index.test.js +134 -0
- package/es/counter/counter-legacy/index.js +267 -0
- package/es/counter/index.js +6 -270
- package/es/counter/style/index.css +1 -1
- package/es/date-picker/BasePicker.js +380 -302
- package/es/date-picker/Calender.js +326 -98
- package/es/date-picker/DatePanel.js +194 -213
- package/es/date-picker/DatePicker.js +143 -47
- package/es/date-picker/DateRangePanel.js +272 -208
- package/es/date-picker/Modal.js +18 -32
- package/es/date-picker/Time.js +231 -345
- package/es/date-picker/TimeList.js +246 -0
- package/es/date-picker/TimePanel.js +28 -41
- package/es/date-picker/TimePeriodPanel.js +27 -46
- package/es/date-picker/TimePicker.js +44 -46
- package/es/date-picker/TimeRangePanel.js +33 -51
- package/es/date-picker/Type.js +5 -1
- package/es/date-picker/WeekRangePanel.js +254 -175
- package/es/date-picker/YMRangePanel.js +364 -0
- package/es/date-picker/__tests__/index.test.js +956 -0
- package/es/date-picker/constants.js +14 -28
- package/es/date-picker/dateUtil.js +221 -52
- package/es/date-picker/datepicker-legacy/BasePicker.js +511 -0
- package/es/date-picker/datepicker-legacy/Calender.js +422 -0
- package/es/date-picker/datepicker-legacy/DatePanel.js +455 -0
- package/es/date-picker/datepicker-legacy/DatePicker.js +103 -0
- package/es/date-picker/datepicker-legacy/DateRangePanel.js +488 -0
- package/es/date-picker/datepicker-legacy/Modal.js +67 -0
- package/es/date-picker/datepicker-legacy/Time.js +405 -0
- package/es/date-picker/datepicker-legacy/TimePanel.js +85 -0
- package/es/date-picker/datepicker-legacy/TimePeriodPanel.js +118 -0
- package/es/date-picker/datepicker-legacy/TimePicker.js +78 -0
- package/es/date-picker/datepicker-legacy/TimeRangePanel.js +90 -0
- package/es/date-picker/datepicker-legacy/Type.js +31 -0
- package/es/date-picker/datepicker-legacy/WeekRangePanel.js +337 -0
- package/es/date-picker/datepicker-legacy/constants.js +79 -0
- package/es/date-picker/datepicker-legacy/dateUtil.js +258 -0
- package/es/date-picker/datepicker-legacy/index.js +15 -0
- package/es/date-picker/datepicker-legacy/local.js +11 -0
- package/es/date-picker/datepicker-legacy/style/index.css +1 -0
- package/es/date-picker/datepicker-legacy/style/index.js +3 -0
- package/es/date-picker/datepicker-legacy/style/timepicker.css +1 -0
- package/es/date-picker/datepicker-legacy/util.js +60 -0
- package/es/date-picker/index.js +5 -2
- package/es/date-picker/style/index.css +1 -1
- package/es/date-picker/toLunar.js +172 -0
- package/es/date-picker/util.js +101 -8
- package/es/dropdown/Dropdown.js +191 -203
- package/es/dropdown/DropdownButton.js +102 -0
- package/es/dropdown/DropdownMenu.js +107 -0
- package/es/dropdown/DropdownMenuItem.js +172 -0
- package/es/dropdown/__tests__/index.test.js +313 -0
- package/es/dropdown/index.js +69 -4
- package/es/dropdown/style/index.css +1 -1
- package/es/dropdown/style/index.js +0 -2
- package/es/dropdown/{__test__ → tests}/index.test.js +7 -7
- package/es/dropdown/utils.js +35 -0
- package/es/ficon/index.js +16 -30
- package/es/form/Form.js +176 -0
- package/es/form/{item.js → Item.js} +52 -60
- package/es/form/__tests__/index.test.js +571 -0
- package/es/form/index.js +6 -171
- package/es/form/style/index.css +1 -1
- package/es/grid/__tests__/index.test.js +100 -0
- package/es/grid/index.js +36 -56
- package/es/icon/index.js +23 -38
- package/es/index.js +61 -9
- package/es/input/Input.js +400 -0
- package/es/input/__tests__/index.test.js +376 -0
- package/es/input/index.js +26 -347
- package/es/input/input-legacy/index.js +341 -0
- package/es/input/input-legacy/util.js +176 -0
- package/es/input/style/index.css +1 -1
- package/es/input/util.js +26 -18
- package/es/lib/withDragDropContext.js +2 -2
- package/es/loading/Loading.js +173 -0
- package/es/loading/__tests__/index.test.js +110 -0
- package/es/loading/index.js +5 -129
- package/es/loading/style/index.css +0 -0
- package/es/loading/style/index.js +0 -0
- package/es/locales/en-US.js +45 -9
- package/es/locales/index.js +16 -2
- package/es/locales/zh-CN.js +46 -10
- package/es/locales/zh-Hant-HK.js +123 -0
- package/es/locales/zh-Hant-TW.js +125 -0
- package/es/menu/Item.js +34 -51
- package/es/menu/Menu.js +414 -0
- package/es/menu/SubMenu.js +63 -90
- package/es/menu/Title.js +37 -51
- package/es/menu/__tests__/index.test.js +274 -0
- package/es/menu/index.js +12 -419
- package/es/menu/style/index.css +1 -1
- package/es/message/__tests__/index.test.js +71 -0
- package/es/message/index.js +58 -0
- package/es/message/style/index.css +1 -0
- package/es/message/style/index.js +5 -0
- package/es/modal/__tests__/index.test.js +178 -0
- package/es/modal/index.js +85 -77
- package/es/modal/style/index.css +1 -1
- package/es/nav-menu/NavMenu.js +44 -61
- package/es/nav-menu/__test__/index.test.js +8 -8
- package/es/nav-menu/__tests__/index.test.js +23 -0
- package/es/nav-menu/index.js +2 -2
- package/es/notice/Notice.js +136 -0
- package/es/notice/NoticeContainer.js +107 -0
- package/es/notice/__tests__/index.test.js +174 -0
- package/es/notice/index.js +66 -0
- package/es/notice/style/index.css +1 -0
- package/es/notice/style/index.js +5 -0
- package/es/notification/HandleNotification/index.js +216 -0
- package/es/notification/HandleNotification/style/index.css +1 -0
- package/es/notification/HandleNotification/style/index.js +5 -0
- package/es/notification/__tests__/index.test.js +114 -0
- package/es/notification/index.js +68 -231
- package/es/notification/style/index.css +1 -1
- package/es/notification/style/index.js +0 -0
- package/es/pagination/Pager.js +7 -9
- package/es/pagination/Pagination.js +134 -133
- package/es/pagination/__tests__/index.test.js +244 -0
- package/es/pagination/index.js +9 -8
- package/es/pagination/style/index.css +1 -1
- package/es/panel/index.js +28 -46
- package/es/popover/__test__/index.test.js +10 -10
- package/es/popover/__tests__/index.test.js +152 -0
- package/es/popover/index.js +77 -83
- package/es/popper/index.js +68 -64
- package/es/popper/style/index.css +1 -1
- package/es/preview/index.js +529 -0
- package/es/preview/style/index.css +1 -0
- package/es/preview/style/index.js +3 -0
- package/es/progress/BarProgress.js +107 -43
- package/es/progress/CircleProgress.js +13 -14
- package/es/progress/DashboardProgress.js +11 -13
- package/es/progress/Progress.js +102 -0
- package/es/progress/__tests__/index.test.js +131 -0
- package/es/progress/index.js +8 -100
- package/es/progress/style/index.css +1 -1
- package/es/radio/Group.js +199 -0
- package/es/radio/Radio.js +147 -0
- package/es/radio/__tests__/index.test.js +127 -0
- package/es/radio/index.js +10 -216
- package/es/radio/{__test__ → radio-legacy/__test__}/index.test.js +13 -13
- package/es/radio/radio-legacy/index.js +214 -0
- package/es/radio/radio-legacy/style/index.css +1 -0
- package/es/radio/radio-legacy/style/index.js +3 -0
- package/es/radio/style/index.css +1 -1
- package/es/rate/Icons.js +70 -70
- package/es/rate/Rate.js +75 -108
- package/es/rate/__tests__/index.test.js +124 -0
- package/es/rate/index.js +5 -2
- package/es/rate/style/index.css +1 -1
- package/es/select/Select.js +330 -265
- package/es/select/SelectDropdown.js +223 -79
- package/es/select/SelectInput.js +120 -91
- package/es/select/__tests__/index.test.js +505 -0
- package/es/select/index.js +6 -4
- package/es/select/select-legacy/Option.js +78 -0
- package/es/select/select-legacy/Select.js +702 -0
- package/es/select/select-legacy/SelectDropdown.js +157 -0
- package/es/select/select-legacy/SelectInput.js +308 -0
- package/es/select/select-legacy/common.js +19 -0
- package/es/select/select-legacy/index.js +16 -0
- package/es/select/style/select-dropdown.css +1 -1
- package/es/select/style/select-input.css +1 -1
- package/es/stepper/Stepper.js +147 -0
- package/es/stepper/__tests__/index.test.js +161 -0
- package/es/stepper/index.js +21 -127
- package/es/stepper/style/index.css +1 -1
- package/es/style/icon/diyIcon.css +1 -1
- package/es/style/icon/index.css +1 -1
- package/es/switch/__tests__/index.test.js +68 -0
- package/es/switch/index.js +26 -46
- package/es/switch/style/index.css +1 -1
- package/es/table/Body.js +294 -0
- package/es/table/ClickOuterside.js +95 -0
- package/es/table/Footer.js +171 -0
- package/es/table/Header.js +320 -0
- package/es/table/TableContent.js +101 -0
- package/es/table/__tests__/index.test.js +129 -0
- package/es/table/checkbox/index.js +36 -47
- package/es/table/checkbox/style/index.css +1 -0
- package/es/table/checkbox/style/index.js +3 -0
- package/es/table/index.js +269 -314
- package/es/table/menu/index.js +34 -44
- package/es/table/prefix.js +2 -2
- package/es/table/style/Table.css +1 -1
- package/es/table/style/index.css +1 -1
- package/es/tabs/ItemDropdown.js +45 -65
- package/es/tabs/TabPane.js +26 -44
- package/es/tabs/Tabs.js +110 -111
- package/es/tabs/__tests__/index.test.js +329 -0
- package/es/tabs/index.js +9 -3
- package/es/tabs/style/index.css +1 -1
- package/es/tabs/tabs-legacy/ItemDropdown.js +162 -0
- package/es/tabs/tabs-legacy/TabPane.js +70 -0
- package/es/tabs/tabs-legacy/Tabs.js +291 -0
- package/es/tabs/tabs-legacy/index.js +18 -0
- package/es/tabs/tabs-legacy/style/index.css +1 -0
- package/es/tabs/tabs-legacy/style/index.js +3 -0
- package/es/tag/__tests__/index.test.js +46 -0
- package/es/tag/index.js +86 -0
- package/es/tag/style/index.css +1 -0
- package/es/tag/style/index.js +3 -0
- package/es/timeline/__tests__/index.test.js +198 -0
- package/es/timeline/index.js +206 -136
- package/es/timeline/style/index.css +1 -1
- package/es/tooltip/__tests__/index.test.js +166 -0
- package/es/tooltip/index.js +93 -52
- package/es/tooltip/style/index.css +1 -1
- package/es/transfer/Item.js +73 -71
- package/es/transfer/Transfer.js +558 -0
- package/es/transfer/__tests__/index.test.js +210 -0
- package/es/transfer/index.js +4 -443
- package/es/transfer/style/index.css +1 -1
- package/es/tree/IconLoading.js +38 -0
- package/es/tree/Tree.js +94 -111
- package/es/tree/TreeDivider.js +6 -6
- package/es/tree/TreeItem.js +217 -123
- package/es/tree/TreeNode.js +472 -333
- package/es/tree/__tests__/index.test.js +599 -0
- package/es/tree/index.js +9 -2
- package/es/tree/style/index.css +1 -1
- package/es/tree/tree-legacy/Tree.js +330 -0
- package/es/tree/tree-legacy/TreeDivider.js +25 -0
- package/es/tree/tree-legacy/TreeItem.js +326 -0
- package/es/tree/tree-legacy/TreeNode.js +711 -0
- package/es/tree/tree-legacy/index.js +13 -0
- package/es/tree/tree-legacy/style/index.css +1 -0
- package/es/tree/tree-legacy/style/index.js +3 -0
- package/es/tree/tree-legacy/util.js +434 -0
- package/es/tree/util.js +8 -256
- package/es/upload/Upload.js +292 -200
- package/es/upload/UploadAvatar.js +61 -79
- package/es/upload/UploadClick.js +62 -60
- package/es/upload/UploadDrag.js +63 -66
- package/es/upload/UploadPhoto.js +86 -75
- package/es/upload/UploadPictureCard.js +53 -60
- package/es/upload/__tests__/index.test.js +760 -0
- package/es/upload/index.js +8 -71
- package/es/upload/main.js +83 -0
- package/es/upload/style/index.css +1 -1
- package/es/upload/tool.js +0 -1
- package/es/upload/{Preview.js → upload-legacy/Preview.js} +48 -62
- package/es/upload/upload-legacy/Upload.js +431 -0
- package/es/upload/upload-legacy/UploadAvatar.js +318 -0
- package/es/upload/upload-legacy/UploadClick.js +121 -0
- package/es/upload/upload-legacy/UploadDrag.js +176 -0
- package/es/upload/upload-legacy/UploadPhoto.js +179 -0
- package/es/upload/upload-legacy/UploadPictureCard.js +122 -0
- package/es/upload/upload-legacy/index.js +67 -0
- package/es/upload/upload-legacy/style/index.css +1 -0
- package/es/upload/upload-legacy/style/index.js +5 -0
- package/es/upload/upload-legacy/tool.js +84 -0
- package/es/watermark/index.js +97 -0
- package/es/watermark/watermark.js +263 -0
- package/package.json +1 -1
- package/es/alert/__test__/index.test.js +0 -67
- package/es/button/__test__/index.test.js +0 -29
- package/es/cascader/__test__/index.test.js +0 -283
- package/es/cascader/menu.js +0 -155
- package/es/checkbox/Base.js +0 -205
- package/es/checkbox/CheckBox.js +0 -185
- package/es/collapse/__test__/index.test.js +0 -58
- package/es/counter/__test__/index.test.js +0 -52
- package/es/menu/ItemGroup.js +0 -81
- package/es/modal/__test__/index.test.js +0 -123
- package/es/notification/__test__/index.test.js +0 -56
- package/es/pagination/__test__/index.test.js +0 -140
- package/es/rate/__test__/index.test.js +0 -54
- package/es/select/Option.js +0 -93
- package/es/select/__test__/index.test.js +0 -429
- package/es/style/color/colors.css +0 -0
- package/es/style/index.css +0 -0
- package/es/style/mixins/colors.css +0 -0
- package/es/style/mixins/index.css +0 -0
- package/es/style/theme/dark.css +0 -0
- package/es/style/theme/default.css +0 -0
- package/es/switch/__test__/index.test.js +0 -39
- package/es/table/__test__/index.test.js +0 -73
- package/es/table/body.js +0 -318
- package/es/table/clickOuterside.js +0 -115
- package/es/table/footer.js +0 -196
- package/es/table/header.js +0 -337
- package/es/table/pover.js +0 -154
- package/es/table/tableContent.js +0 -120
- package/es/timeline/__test__/index.test.js +0 -49
- package/es/timeline/foldingItem.js +0 -82
- package/es/tooltip/__test__/index.test.js +0 -67
- package/es/transfer/__test__/index.test.js +0 -11
- /package/es/{style → breadcrumb/style}/index.js +0 -0
- /package/es/checkbox/{common.js → checkbox-legacy/common.js} +0 -0
- /package/es/upload/{style → upload-legacy/style}/preview.css +0 -0
- /package/es/upload/{style → upload-legacy/style}/preview.js +0 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
|
|
9
|
+
var _enzyme = require("enzyme");
|
|
10
|
+
|
|
11
|
+
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
|
|
12
|
+
|
|
13
|
+
var _Pagination = _interopRequireWildcard(require("../Pagination"));
|
|
14
|
+
|
|
15
|
+
var _simulant = _interopRequireDefault(require("simulant"));
|
|
16
|
+
|
|
17
|
+
var _Input = _interopRequireDefault(require("../../input/Input"));
|
|
18
|
+
|
|
19
|
+
/* eslint-env jest */
|
|
20
|
+
var jumpCallback = jest.fn(function (key) {
|
|
21
|
+
return key;
|
|
22
|
+
});
|
|
23
|
+
var sizeChangeCallback = jest.fn(function (val, current) {
|
|
24
|
+
return [val, current];
|
|
25
|
+
});
|
|
26
|
+
var pageChangeCallback = jest.fn(function (page, prevPage, pageSize) {
|
|
27
|
+
return [page, prevPage, pageSize];
|
|
28
|
+
});
|
|
29
|
+
var pageSizeOptions = [{
|
|
30
|
+
value: 10,
|
|
31
|
+
title: '10'
|
|
32
|
+
}, {
|
|
33
|
+
value: 20,
|
|
34
|
+
title: '20'
|
|
35
|
+
}, {
|
|
36
|
+
value: 50,
|
|
37
|
+
title: '50'
|
|
38
|
+
}, {
|
|
39
|
+
value: 100,
|
|
40
|
+
title: '100'
|
|
41
|
+
}];
|
|
42
|
+
describe('Pagination', function () {
|
|
43
|
+
describe('PropTypes', function () {
|
|
44
|
+
it('type', function () {
|
|
45
|
+
var types = ['default', 'simple', 'shrink'];
|
|
46
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement("div", null, types.map(function (type, index) {
|
|
47
|
+
return _react["default"].createElement(_Pagination["default"], {
|
|
48
|
+
total: 100,
|
|
49
|
+
pageSize: 10,
|
|
50
|
+
type: type,
|
|
51
|
+
key: index
|
|
52
|
+
});
|
|
53
|
+
})));
|
|
54
|
+
types.map(function (type) {
|
|
55
|
+
expect(wrapper.find(".hi-pagination--".concat(type))).toHaveLength(1);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it('total & defaultCurrent', function () {
|
|
59
|
+
var dc = 2;
|
|
60
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
61
|
+
total: 100,
|
|
62
|
+
pageSize: 10,
|
|
63
|
+
defaultCurrent: dc
|
|
64
|
+
}));
|
|
65
|
+
expect(wrapper.find(".hi-pagination__item-".concat(dc)).hasClass('hi-pagination__item--active')).toBeTruthy();
|
|
66
|
+
wrapper.setProps({
|
|
67
|
+
defaultCurrent: 3
|
|
68
|
+
});
|
|
69
|
+
expect(wrapper.find(".hi-pagination__item-".concat(dc)).hasClass('hi-pagination__item--active')).toBeTruthy();
|
|
70
|
+
wrapper.setProps({
|
|
71
|
+
total: 200
|
|
72
|
+
});
|
|
73
|
+
expect(wrapper.find('.hi-pagination__item-20')).toHaveLength(1);
|
|
74
|
+
});
|
|
75
|
+
it('current', function () {
|
|
76
|
+
var dc = 2;
|
|
77
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
78
|
+
total: 100,
|
|
79
|
+
pageSize: 10,
|
|
80
|
+
current: dc
|
|
81
|
+
}));
|
|
82
|
+
expect(wrapper.find(".hi-pagination__item-".concat(dc)).hasClass('hi-pagination__item--active')).toBeTruthy();
|
|
83
|
+
wrapper.setProps({
|
|
84
|
+
current: 3
|
|
85
|
+
});
|
|
86
|
+
expect(wrapper.find(".hi-pagination__item-3").hasClass('hi-pagination__item--active')).toBeTruthy();
|
|
87
|
+
wrapper.setProps({
|
|
88
|
+
current: 0
|
|
89
|
+
});
|
|
90
|
+
expect(wrapper.find(".hi-pagination__item-1").hasClass('hi-pagination__item--active')).toBeTruthy();
|
|
91
|
+
wrapper.setProps({
|
|
92
|
+
current: 100
|
|
93
|
+
});
|
|
94
|
+
expect(wrapper.find(".hi-pagination__item-10").hasClass('hi-pagination__item--active')).toBeTruthy();
|
|
95
|
+
});
|
|
96
|
+
it('max', function () {
|
|
97
|
+
// TODO:MAX 属性
|
|
98
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
99
|
+
current: 1,
|
|
100
|
+
total: 200,
|
|
101
|
+
pageSize: 10
|
|
102
|
+
}));
|
|
103
|
+
wrapper.setProps({
|
|
104
|
+
current: 3
|
|
105
|
+
});
|
|
106
|
+
expect(wrapper.find(".hi-pagination__item-3").hasClass('hi-pagination__item--active')).toBeTruthy();
|
|
107
|
+
wrapper.find('.hi-pagination__item-1').at(0).simulate('click');
|
|
108
|
+
wrapper.find('.hi-pagination__item-4').at(0).simulate('click');
|
|
109
|
+
});
|
|
110
|
+
it('pageSize', function () {
|
|
111
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
112
|
+
total: 100,
|
|
113
|
+
pageSize: 10
|
|
114
|
+
}));
|
|
115
|
+
expect(wrapper.find(".hi-pagination__item-10")).toHaveLength(1);
|
|
116
|
+
wrapper.setProps({
|
|
117
|
+
pageSize: 5
|
|
118
|
+
});
|
|
119
|
+
expect(wrapper.find(".hi-pagination__item-20")).toHaveLength(1);
|
|
120
|
+
});
|
|
121
|
+
it('pageSizeOptions && onPageSizeChange', function () {
|
|
122
|
+
var callback = jest.fn();
|
|
123
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
124
|
+
total: 100,
|
|
125
|
+
pageSize: 10,
|
|
126
|
+
pageSizeOptions: [10, 20, 50],
|
|
127
|
+
onPageSizeChange: callback
|
|
128
|
+
}));
|
|
129
|
+
expect(wrapper.find('.hi-pagination__sizes')).toHaveLength(1);
|
|
130
|
+
wrapper.find('.hi-select__input').simulate('click');
|
|
131
|
+
|
|
132
|
+
_testUtils["default"].Simulate.click(document.querySelectorAll('.hi-select__dropdown--item')[1]);
|
|
133
|
+
|
|
134
|
+
expect(callback).toHaveBeenCalled();
|
|
135
|
+
expect(callback).toHaveBeenCalledWith(20, 1);
|
|
136
|
+
expect(wrapper.find(_Pagination.Pagination).state('pageSize')).toEqual(20);
|
|
137
|
+
});
|
|
138
|
+
it('autoHide', function () {
|
|
139
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
140
|
+
total: 10,
|
|
141
|
+
pageSize: 10,
|
|
142
|
+
autoHide: true
|
|
143
|
+
}));
|
|
144
|
+
expect(wrapper.find('.hi-pagination')).toHaveLength(0);
|
|
145
|
+
});
|
|
146
|
+
it('showJumper', function () {
|
|
147
|
+
var callback = jest.fn();
|
|
148
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
149
|
+
total: 20,
|
|
150
|
+
pageSize: 10,
|
|
151
|
+
showJumper: true,
|
|
152
|
+
onJump: callback
|
|
153
|
+
}));
|
|
154
|
+
expect(wrapper.find('.hi-pagination__jumper')).toHaveLength(1); // wrapper.find(Pagination).setState({jumpTo: 2})
|
|
155
|
+
// wrapper.find('.hi-input__text').simulate('change')
|
|
156
|
+
|
|
157
|
+
wrapper.find('.hi-input__text').simulate('blur', {
|
|
158
|
+
target: {
|
|
159
|
+
value: 2
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
expect(callback).toHaveBeenCalled();
|
|
163
|
+
expect(callback).toHaveBeenCalledWith(2);
|
|
164
|
+
wrapper.find('.hi-input__text').simulate('keypress', {
|
|
165
|
+
type: 'keypress',
|
|
166
|
+
charCode: 13
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
it('onChange', function () {
|
|
170
|
+
var callback = jest.fn();
|
|
171
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
172
|
+
total: 100,
|
|
173
|
+
pageSize: 10,
|
|
174
|
+
showJumper: true,
|
|
175
|
+
onChange: callback
|
|
176
|
+
}));
|
|
177
|
+
wrapper.find('.hi-pagination__item-2').at(0).simulate('click');
|
|
178
|
+
expect(callback).toHaveBeenCalled();
|
|
179
|
+
expect(callback).toHaveBeenCalledWith(2, 1, 10);
|
|
180
|
+
wrapper.find(_Pagination.Pagination).setState({
|
|
181
|
+
jumpTo: ''
|
|
182
|
+
});
|
|
183
|
+
wrapper.find('.hi-input__text').simulate('change');
|
|
184
|
+
wrapper.find(_Pagination.Pagination).setState({
|
|
185
|
+
jumpTo: 3
|
|
186
|
+
});
|
|
187
|
+
wrapper.find('.hi-input__text').simulate('change');
|
|
188
|
+
expect(callback).toHaveBeenCalledWith(2, 1, 10);
|
|
189
|
+
wrapper.find(_Pagination.Pagination).setState({
|
|
190
|
+
jumpTo: 0
|
|
191
|
+
});
|
|
192
|
+
wrapper.find('.hi-input__text').simulate('change');
|
|
193
|
+
wrapper.find(_Pagination.Pagination).setState({
|
|
194
|
+
jumpTo: 'ab'
|
|
195
|
+
});
|
|
196
|
+
wrapper.find('.hi-input__text').simulate('change');
|
|
197
|
+
wrapper.find('.hi-input__text').simulate('change', {
|
|
198
|
+
target: {
|
|
199
|
+
value: 5
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
expect(wrapper.find(_Pagination.Pagination).state('jumpTo')).toEqual(5);
|
|
203
|
+
wrapper.find('.hi-input__text').simulate('change', {
|
|
204
|
+
target: {
|
|
205
|
+
value: 50
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
expect(wrapper.find(_Pagination.Pagination).state('jumpTo')).toEqual(10);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
describe('Branches', function () {
|
|
212
|
+
it('Normal', function () {
|
|
213
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
214
|
+
total: 100,
|
|
215
|
+
pageSize: 10,
|
|
216
|
+
showTotal: true
|
|
217
|
+
}));
|
|
218
|
+
expect(wrapper.find('.hi-pagination__total')).toHaveLength(1);
|
|
219
|
+
});
|
|
220
|
+
it('Shrink', function () {
|
|
221
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
222
|
+
total: 1,
|
|
223
|
+
pageSize: 10,
|
|
224
|
+
type: "shrink",
|
|
225
|
+
showJumper: true
|
|
226
|
+
}));
|
|
227
|
+
expect(wrapper.find('.hi-pagination__jumper-input')).toHaveLength(1);
|
|
228
|
+
});
|
|
229
|
+
it('PageSizeOption', function () {
|
|
230
|
+
var callback = jest.fn();
|
|
231
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_Pagination["default"], {
|
|
232
|
+
total: 100,
|
|
233
|
+
pageSize: 10,
|
|
234
|
+
pageSizeOptions: [{
|
|
235
|
+
value: 10
|
|
236
|
+
}, {
|
|
237
|
+
value: 20
|
|
238
|
+
}],
|
|
239
|
+
onPageSizeChange: callback
|
|
240
|
+
}));
|
|
241
|
+
expect(wrapper.find('.hi-pagination__sizes')).toHaveLength(1);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
});
|
package/es/pagination/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return _Pagination["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _Pagination = _interopRequireDefault(require("./Pagination"));
|
|
12
11
|
|
|
13
12
|
require("./style/index");
|
|
14
13
|
|
|
15
|
-
var
|
|
14
|
+
var _util = require("../_util");
|
|
15
|
+
|
|
16
|
+
var _default = (0, _util.depreactedPropsCompat)([['type', 'mode'], ['max', 'pageBufferSize'], ['autoHide', 'hideOnSinglePage'], ['showJumper', 'showQuickJumper'], ['onPageSizeChange', 'sizeChangeEvent']])(_Pagination["default"]);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
exports["default"] = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.hi-pagination{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font:normal 14px/1.5 -apple-system,BlinkMacSystemFont,"Helvetica Neue",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";text-align:left;text-indent:0;text-shadow:none;text-transform:none;letter-spacing:0;word-spacing:normal;white-space:normal;color:#333}.hi-pagination a{padding-left:0;padding-right:0}.hi-pagination p,.hi-pagination blockquote,.hi-pagination ul,.hi-pagination ol,.hi-pagination dl,.hi-pagination table,.hi-pagination pre,.hi-pagination h1,.hi-pagination h2,.hi-pagination h3,.hi-pagination h4,.hi-pagination h5,.hi-pagination h6{margin-top:0;margin-bottom:0}.hi-pagination ul,.hi-pagination ol{margin:0;padding:0;list-style-type:none}.hi-pagination ul ul,.hi-pagination ul ol,.hi-pagination ol ul,.hi-pagination ol ol{margin-top:0;margin-bottom:0}.hi-pagination li+li{margin-top:0}.hi-pagination dl{margin-top:0;margin-bottom:0}.hi-pagination__text{line-height:32px;color:#666}.hi-pagination__total{margin-right:16px}.hi-pagination__sizes{margin-right:16px}.hi-pagination__jumper{margin-left:16px}.hi-pagination__span{display:inline-block;margin:0 4px}.hi-pagination__jumper-input{display:inline-block;margin:0
|
|
1
|
+
.hi-pagination{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font:normal 14px/1.5 -apple-system,BlinkMacSystemFont,"Helvetica Neue",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";text-align:left;text-indent:0;text-shadow:none;text-transform:none;letter-spacing:0;word-spacing:normal;white-space:normal;color:#333}.hi-pagination a{padding-left:0;padding-right:0}.hi-pagination p,.hi-pagination blockquote,.hi-pagination ul,.hi-pagination ol,.hi-pagination dl,.hi-pagination table,.hi-pagination pre,.hi-pagination h1,.hi-pagination h2,.hi-pagination h3,.hi-pagination h4,.hi-pagination h5,.hi-pagination h6{margin-top:0;margin-bottom:0}.hi-pagination ul,.hi-pagination ol{margin:0;padding:0;list-style-type:none}.hi-pagination ul ul,.hi-pagination ul ol,.hi-pagination ol ul,.hi-pagination ol ol{margin-top:0;margin-bottom:0}.hi-pagination li+li{margin-top:0}.hi-pagination dl{margin-top:0;margin-bottom:0}.hi-pagination__text{line-height:32px;color:#666}.hi-pagination__total{margin-right:16px}.hi-pagination__sizes{margin-right:16px}.hi-pagination__jumper{margin-left:16px}.hi-pagination__span{display:inline-block;margin:0 4px}.hi-pagination__span .hi-select__input{border:1px solid #e7e7e7}.hi-pagination__jumper-input{display:inline-block;margin:0 20px 0 8px;color:#666}.hi-pagination__jumper-input .hi-input{width:64px}.hi-pagination__jumper-input .hi-input__inner{border:1px solid #e7e7e7}.hi-pagination__jumper-input .hi-input__text{text-align:center}.hi-pagination__jumper-input .hi-input__fix-box{display:none}.hi-pagination__item{float:left}.hi-pagination__item+.hi-pagination__item{margin-left:8px}.hi-pagination__item-break{width:32px;text-align:center}.hi-pagination__item>span{-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;min-width:32px;padding:0 4px;height:32px;border:1px solid #e7e7e7;border-radius:2px;font-size:14px;line-height:30px;text-decoration:none;text-align:center;color:#666;cursor:pointer}.hi-pagination__item>span:hover{border:1px solid transparent;-webkit-transition:border-color .15s linear,color .15s linear;transition:border-color .15s linear,color .15s linear}.hi-pagination__item--active>span{border:1px solid transparent}.hi-pagination__item--disabled>span{border:1px solid #e7e7e7;color:#e7e7e7;cursor:default}.hi-pagination__item--disabled>span:hover{border:1px solid #e7e7e7}.hi-pagination .hi-dropdown-menu{min-width:0}.hi-pagination__item:not(.hi-pagination__item--disabled)>span:hover{border-color:rgba(66,133,244,0.8);color:#4285f4}.hi-pagination__item--active:not(.hi-pagination__item--disabled)>span{border-color:#4285f4;background-color:#4285f4;color:#fff;cursor:default}.hi-pagination__item--active:not(.hi-pagination__item--disabled)>span:hover{border-color:#4285f4;color:#fff}.theme__orange .hi-pagination__item:not(.hi-pagination__item--disabled)>span:hover{border-color:rgba(255,102,51,0.8);color:#f63}.theme__orange .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span{border-color:#f63;background-color:#f63;color:#fff;cursor:default}.theme__orange .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span:hover{border-color:#f63;color:#fff}.theme__cyan .hi-pagination__item:not(.hi-pagination__item--disabled)>span:hover{border-color:rgba(70,188,153,0.8);color:#46bc99}.theme__cyan .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span{border-color:#46bc99;background-color:#46bc99;color:#fff;cursor:default}.theme__cyan .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span:hover{border-color:#46bc99;color:#fff}.theme__magenta .hi-pagination__item:not(.hi-pagination__item--disabled)>span:hover{border-color:rgba(255,89,117,0.8);color:#ff5975}.theme__magenta .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span{border-color:#ff5975;background-color:#ff5975;color:#fff;cursor:default}.theme__magenta .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span:hover{border-color:#ff5975;color:#fff}.theme__lavender .hi-pagination__item:not(.hi-pagination__item--disabled)>span:hover{border-color:rgba(180,80,222,0.8);color:#b450de}.theme__lavender .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span{border-color:#b450de;background-color:#b450de;color:#fff;cursor:default}.theme__lavender .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span:hover{border-color:#b450de;color:#fff}.theme__blue .hi-pagination__item:not(.hi-pagination__item--disabled)>span:hover{border-color:rgba(61,168,245,0.8);color:#3da8f5}.theme__blue .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span{border-color:#3da8f5;background-color:#3da8f5;color:#fff;cursor:default}.theme__blue .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span:hover{border-color:#3da8f5;color:#fff}.theme__purple .hi-pagination__item:not(.hi-pagination__item--disabled)>span:hover{border-color:rgba(138,138,203,0.8);color:#8a8acb}.theme__purple .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span{border-color:#8a8acb;background-color:#8a8acb;color:#fff;cursor:default}.theme__purple .hi-pagination__item--active:not(.hi-pagination__item--disabled)>span:hover{border-color:#8a8acb;color:#fff}
|
package/es/panel/index.js
CHANGED
|
@@ -1,60 +1,45 @@
|
|
|
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
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
require("./style/index");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
21
13
|
|
|
22
|
-
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
23
15
|
|
|
24
|
-
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
17
|
|
|
26
|
-
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
19
|
|
|
28
|
-
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
29
21
|
|
|
30
|
-
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
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); }; }
|
|
35
|
-
|
|
36
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
37
|
-
|
|
38
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
-
|
|
40
|
-
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; } }
|
|
24
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
41
25
|
|
|
42
|
-
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
_inherits(Panel, _Component);
|
|
30
|
+
require("./style/index");
|
|
48
31
|
|
|
49
|
-
|
|
32
|
+
var Panel =
|
|
33
|
+
/*#__PURE__*/
|
|
34
|
+
function (_Component) {
|
|
35
|
+
(0, _inherits2["default"])(Panel, _Component);
|
|
50
36
|
|
|
51
37
|
function Panel() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return _super.apply(this, arguments);
|
|
38
|
+
(0, _classCallCheck2["default"])(this, Panel);
|
|
39
|
+
return (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Panel).apply(this, arguments));
|
|
55
40
|
}
|
|
56
41
|
|
|
57
|
-
|
|
42
|
+
(0, _createClass2["default"])(Panel, [{
|
|
58
43
|
key: "render",
|
|
59
44
|
value: function render() {
|
|
60
45
|
var classnames = (0, _classnames["default"])(this.props.prefixCls, this.props.type);
|
|
@@ -63,34 +48,31 @@ var Panel = /*#__PURE__*/function (_Component) {
|
|
|
63
48
|
footer = _this$props.footer,
|
|
64
49
|
children = _this$props.children,
|
|
65
50
|
icon = _this$props.icon;
|
|
66
|
-
return
|
|
51
|
+
return _react["default"].createElement("div", {
|
|
67
52
|
className: classnames
|
|
68
|
-
},
|
|
53
|
+
}, _react["default"].createElement("div", {
|
|
69
54
|
className: "panel-title"
|
|
70
|
-
}, icon &&
|
|
55
|
+
}, icon && _react["default"].createElement("i", {
|
|
71
56
|
className: (0, _classnames["default"])('hi-icon', icon)
|
|
72
|
-
}), title),
|
|
57
|
+
}), title), _react["default"].createElement("div", {
|
|
73
58
|
className: "panel-content"
|
|
74
|
-
}, children), typeof footer !== 'undefined' &&
|
|
59
|
+
}, children), typeof footer !== 'undefined' && _react["default"].createElement("div", {
|
|
75
60
|
className: "panel-footer"
|
|
76
61
|
}, footer));
|
|
77
62
|
}
|
|
78
63
|
}]);
|
|
79
|
-
|
|
80
64
|
return Panel;
|
|
81
65
|
}(_react.Component);
|
|
82
66
|
|
|
83
|
-
|
|
67
|
+
(0, _defineProperty2["default"])(Panel, "propTypes", {
|
|
84
68
|
title: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]),
|
|
85
69
|
footer: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]),
|
|
86
70
|
icon: _propTypes["default"].string,
|
|
87
71
|
type: _propTypes["default"].string
|
|
88
72
|
});
|
|
89
|
-
|
|
90
|
-
_defineProperty(Panel, "defaultProps", {
|
|
73
|
+
(0, _defineProperty2["default"])(Panel, "defaultProps", {
|
|
91
74
|
prefixCls: 'hi-panel',
|
|
92
75
|
type: 'info'
|
|
93
76
|
});
|
|
94
|
-
|
|
95
77
|
var _default = Panel;
|
|
96
78
|
exports["default"] = _default;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
var _react = _interopRequireDefault(require("react"));
|
|
4
6
|
|
|
5
7
|
var _enzyme = require("enzyme");
|
|
@@ -8,9 +10,7 @@ var _ = _interopRequireDefault(require("../"));
|
|
|
8
10
|
|
|
9
11
|
var _button = _interopRequireDefault(require("../../button"));
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var topClickTarget = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_["default"], {
|
|
13
|
+
var topClickTarget = (0, _enzyme.mount)(_react["default"].createElement("div", null, _react["default"].createElement(_["default"], {
|
|
14
14
|
title: "popover title",
|
|
15
15
|
content: "popover content",
|
|
16
16
|
style: {
|
|
@@ -18,10 +18,10 @@ var topClickTarget = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createEl
|
|
|
18
18
|
},
|
|
19
19
|
placement: "top",
|
|
20
20
|
trigger: "click"
|
|
21
|
-
},
|
|
21
|
+
}, _react["default"].createElement(_button["default"], {
|
|
22
22
|
type: "line"
|
|
23
23
|
}, "Top & click\u89E6\u53D1"))));
|
|
24
|
-
var focusRightTarget = (0, _enzyme.mount)(
|
|
24
|
+
var focusRightTarget = (0, _enzyme.mount)(_react["default"].createElement("div", null, _react["default"].createElement(_["default"], {
|
|
25
25
|
title: "popover title",
|
|
26
26
|
content: "popover content",
|
|
27
27
|
style: {
|
|
@@ -29,23 +29,23 @@ var focusRightTarget = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].create
|
|
|
29
29
|
},
|
|
30
30
|
placement: "right",
|
|
31
31
|
trigger: "focus"
|
|
32
|
-
},
|
|
32
|
+
}, _react["default"].createElement(_button["default"], {
|
|
33
33
|
type: "success"
|
|
34
34
|
}, "Right & focus\u89E6\u53D1"))));
|
|
35
|
-
var leftTarget = (0, _enzyme.mount)(
|
|
35
|
+
var leftTarget = (0, _enzyme.mount)(_react["default"].createElement(_["default"], {
|
|
36
36
|
title: "popover title",
|
|
37
37
|
content: "popover content",
|
|
38
38
|
placement: "left",
|
|
39
39
|
trigger: "click"
|
|
40
|
-
},
|
|
40
|
+
}, _react["default"].createElement(_button["default"], {
|
|
41
41
|
type: "line"
|
|
42
42
|
}, "left")));
|
|
43
|
-
var bottomTarget = (0, _enzyme.mount)(
|
|
43
|
+
var bottomTarget = (0, _enzyme.mount)(_react["default"].createElement(_["default"], {
|
|
44
44
|
title: "popover title",
|
|
45
45
|
content: "popover content",
|
|
46
46
|
placement: "bottom",
|
|
47
47
|
trigger: "click"
|
|
48
|
-
},
|
|
48
|
+
}, _react["default"].createElement(_button["default"], {
|
|
49
49
|
type: "line"
|
|
50
50
|
}, "bottom")));
|
|
51
51
|
describe('Tooltip', function () {
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _enzyme = require("enzyme");
|
|
8
|
+
|
|
9
|
+
var _sinon = _interopRequireDefault(require("sinon"));
|
|
10
|
+
|
|
11
|
+
var _ = _interopRequireDefault(require("../"));
|
|
12
|
+
|
|
13
|
+
var _button = _interopRequireDefault(require("../../button"));
|
|
14
|
+
|
|
15
|
+
var title = _react["default"].createElement("span", null, "Popover Title");
|
|
16
|
+
|
|
17
|
+
var content = _react["default"].createElement("div", null, _react["default"].createElement("p", null, "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."));
|
|
18
|
+
|
|
19
|
+
var topClickTarget = (0, _enzyme.mount)(_react["default"].createElement("div", null, _react["default"].createElement(_["default"], {
|
|
20
|
+
title: title,
|
|
21
|
+
content: content,
|
|
22
|
+
style: {
|
|
23
|
+
margin: '10px 10px'
|
|
24
|
+
},
|
|
25
|
+
placement: "top",
|
|
26
|
+
trigger: "click"
|
|
27
|
+
}, _react["default"].createElement(_button["default"], {
|
|
28
|
+
type: "line"
|
|
29
|
+
}, "Top & click\u89E6\u53D1"))));
|
|
30
|
+
var hoverClickTarget = (0, _enzyme.mount)(_react["default"].createElement(_["default"], {
|
|
31
|
+
title: title,
|
|
32
|
+
content: content,
|
|
33
|
+
style: {
|
|
34
|
+
margin: '10px 10px'
|
|
35
|
+
},
|
|
36
|
+
placement: "top",
|
|
37
|
+
trigger: "hover"
|
|
38
|
+
}, _react["default"].createElement(_button["default"], {
|
|
39
|
+
type: "success"
|
|
40
|
+
}, "Right & hover\u89E6\u53D1")));
|
|
41
|
+
var focusRightTarget = (0, _enzyme.mount)(_react["default"].createElement("div", null, _react["default"].createElement(_["default"], {
|
|
42
|
+
title: "popover title",
|
|
43
|
+
content: "popover content",
|
|
44
|
+
style: {
|
|
45
|
+
margin: '10px 10px'
|
|
46
|
+
},
|
|
47
|
+
placement: "right",
|
|
48
|
+
trigger: "focus"
|
|
49
|
+
}, _react["default"].createElement(_button["default"], {
|
|
50
|
+
type: "success"
|
|
51
|
+
}, "Right & focus\u89E6\u53D1"))));
|
|
52
|
+
var leftTarget = (0, _enzyme.mount)(_react["default"].createElement(_["default"], {
|
|
53
|
+
title: "popover title",
|
|
54
|
+
content: "popover content",
|
|
55
|
+
placement: "left",
|
|
56
|
+
trigger: "click"
|
|
57
|
+
}, _react["default"].createElement(_button["default"], {
|
|
58
|
+
type: "line"
|
|
59
|
+
}, "left")));
|
|
60
|
+
var bottomTarget = (0, _enzyme.mount)(_react["default"].createElement(_["default"], {
|
|
61
|
+
title: "popover title",
|
|
62
|
+
content: "popover content",
|
|
63
|
+
placement: "bottom",
|
|
64
|
+
trigger: "click"
|
|
65
|
+
}, _react["default"].createElement(_button["default"], {
|
|
66
|
+
type: "line"
|
|
67
|
+
}, "bottom")));
|
|
68
|
+
describe('Tooltip', function () {
|
|
69
|
+
var clock;
|
|
70
|
+
beforeEach(function () {
|
|
71
|
+
clock = _sinon["default"].useFakeTimers();
|
|
72
|
+
});
|
|
73
|
+
afterEach(function () {
|
|
74
|
+
clock.restore();
|
|
75
|
+
});
|
|
76
|
+
it('trigger', function () {
|
|
77
|
+
expect(document.querySelectorAll('.hi-popover__popper')).toHaveLength(0);
|
|
78
|
+
topClickTarget.find('button').getDOMNode().click();
|
|
79
|
+
expect(document.querySelectorAll('.hi-popover__popper')).toHaveLength(1);
|
|
80
|
+
trigger(document.querySelectorAll('.hi-popover__popper')[0], 'mouseenter');
|
|
81
|
+
trigger(document.querySelectorAll('.hi-popover__popper')[0], 'mouseout');
|
|
82
|
+
trigger(document.querySelectorAll('.hi-popover__popper')[0], 'mouseover');
|
|
83
|
+
document.body.click();
|
|
84
|
+
expect(document.querySelectorAll('.hi-popper__container--hide')).toHaveLength(1);
|
|
85
|
+
focusRightTarget.find('button').getDOMNode().focus();
|
|
86
|
+
expect(document.querySelectorAll('.hi-popover__popper')).toHaveLength(2);
|
|
87
|
+
focusRightTarget.find('button').getDOMNode().blur();
|
|
88
|
+
expect(document.querySelectorAll('.hi-popper__container--hide')).toHaveLength(2);
|
|
89
|
+
expect(hoverClickTarget.find('button')).toHaveLength(1);
|
|
90
|
+
|
|
91
|
+
function trigger(elem, event) {
|
|
92
|
+
var myEvent = document.createEvent('Event'); // 初始化这个事件对象,为它提高需要的“特性”
|
|
93
|
+
|
|
94
|
+
myEvent.initEvent(event, true, true); //执行事件
|
|
95
|
+
|
|
96
|
+
elem.dispatchEvent(myEvent);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
trigger(hoverClickTarget.find('button').getDOMNode(), 'mouseenter');
|
|
100
|
+
clock.tick(200);
|
|
101
|
+
expect(document.querySelectorAll('.hi-popover__popper')).toHaveLength(3);
|
|
102
|
+
trigger(hoverClickTarget.find('button').getDOMNode(), 'mouseleave');
|
|
103
|
+
clock.tick(200);
|
|
104
|
+
expect(document.querySelectorAll('.hi-popper__container--hide')).toHaveLength(3);
|
|
105
|
+
trigger(hoverClickTarget.find('button').getDOMNode(), 'mouseenter');
|
|
106
|
+
trigger(document.querySelectorAll('.hi-popover__popper')[1], 'mouseover');
|
|
107
|
+
clock.tick(200);
|
|
108
|
+
expect(document.querySelectorAll('.hi-popover__popper')).toHaveLength(3);
|
|
109
|
+
trigger(document.querySelectorAll('.hi-popover__popper')[1], 'mouseout');
|
|
110
|
+
expect(document.querySelectorAll('.hi-popover__popper')).toHaveLength(3);
|
|
111
|
+
});
|
|
112
|
+
it('placement', function () {
|
|
113
|
+
topClickTarget.find('button').getDOMNode().click();
|
|
114
|
+
leftTarget.find('button').getDOMNode().click();
|
|
115
|
+
bottomTarget.find('button').getDOMNode().click();
|
|
116
|
+
expect(document.querySelectorAll('.hi-popper__content--top')).toHaveLength(2);
|
|
117
|
+
expect(document.querySelectorAll('.hi-popper__content--right')).toHaveLength(1);
|
|
118
|
+
expect(document.querySelectorAll('.hi-popper__content--left')).toHaveLength(1);
|
|
119
|
+
expect(document.querySelectorAll('.hi-popper__content--bottom')).toHaveLength(1);
|
|
120
|
+
topClickTarget.unmount();
|
|
121
|
+
hoverClickTarget.unmount();
|
|
122
|
+
focusRightTarget.unmount();
|
|
123
|
+
leftTarget.unmount();
|
|
124
|
+
bottomTarget.unmount();
|
|
125
|
+
});
|
|
126
|
+
it('showPopper', function () {
|
|
127
|
+
// const componentDidMountSpy = spy(Popover.prototype, 'componentDidMount')
|
|
128
|
+
var title = _react["default"].createElement("span", null, "Popover Title");
|
|
129
|
+
|
|
130
|
+
var content = _react["default"].createElement("div", null, _react["default"].createElement("p", null, "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."));
|
|
131
|
+
|
|
132
|
+
var wrapper = (0, _enzyme.mount)(_react["default"].createElement(_["default"], {
|
|
133
|
+
title: title,
|
|
134
|
+
content: content,
|
|
135
|
+
style: {
|
|
136
|
+
margin: '10px 10px'
|
|
137
|
+
},
|
|
138
|
+
placement: "top",
|
|
139
|
+
trigger: "click"
|
|
140
|
+
}, _react["default"].createElement(_button["default"], {
|
|
141
|
+
type: "success"
|
|
142
|
+
}, "Right & hover\u89E6\u53D1")));
|
|
143
|
+
wrapper.find('button').getDOMNode().click();
|
|
144
|
+
expect(document.querySelectorAll('.hi-popover__popper')).toHaveLength(1);
|
|
145
|
+
wrapper.setState({
|
|
146
|
+
showPopper: true
|
|
147
|
+
});
|
|
148
|
+
wrapper.find('button').getDOMNode().click();
|
|
149
|
+
expect(document.querySelectorAll('.hi-popper__container--hide')).toHaveLength(1);
|
|
150
|
+
wrapper.unmount();
|
|
151
|
+
});
|
|
152
|
+
});
|