shineout 1.7.1 → 1.8.0-beta.2
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/css/DatePicker/utils.js +1 -1
- package/css/Form/Field.js +8 -4
- package/css/Form/Form.js +3 -0
- package/css/Form/Item.js +1 -1
- package/css/Form/index.d.ts +1 -0
- package/css/Form/inputable.js +1 -1
- package/css/Pagination/Jumper.js +3 -0
- package/css/index.d.ts +1 -1
- package/css/index.js +1 -1
- package/dist/shineout.js +24 -14
- package/dist/shineout.js.map +1 -1
- package/dist/shineout.min.js +1 -1
- package/es/Alert/index.js +127 -107
- package/es/Alert/styles/index.js +3 -4
- package/es/AnimationList/AbsoluteList.js +257 -193
- package/es/AnimationList/LazyList.js +120 -92
- package/es/AnimationList/List.js +43 -23
- package/es/AnimationList/index.js +19 -14
- package/es/AnimationList/styles/index.js +3 -4
- package/es/Breadcrumb/index.js +77 -69
- package/es/Breadcrumb/styles/index.js +3 -4
- package/es/Button/Button.js +91 -74
- package/es/Button/Group.js +42 -28
- package/es/Button/Once.js +39 -23
- package/es/Button/index.js +7 -10
- package/es/Button/styles/index.js +3 -4
- package/es/Card/Accordion.js +58 -45
- package/es/Card/Body.js +55 -42
- package/es/Card/Card.js +85 -79
- package/es/Card/Footer.js +38 -15
- package/es/Card/Header.js +52 -34
- package/es/Card/Submit.js +51 -33
- package/es/Card/context.js +22 -16
- package/es/Card/index.js +16 -19
- package/es/Card/styles/index.js +3 -4
- package/es/CardGroup/CardGroup.js +93 -69
- package/es/CardGroup/Item.js +61 -43
- package/es/CardGroup/context.js +12 -10
- package/es/CardGroup/index.js +7 -10
- package/es/CardGroup/styles/index.js +3 -4
- package/es/Carousel/Item.js +31 -17
- package/es/Carousel/index.js +156 -123
- package/es/Carousel/styles/index.js +3 -4
- package/es/Cascader/Cascader.js +397 -346
- package/es/Cascader/FilterList.js +185 -142
- package/es/Cascader/Input.js +102 -79
- package/es/Cascader/List.js +66 -41
- package/es/Cascader/Node.js +153 -110
- package/es/Cascader/Result.js +289 -232
- package/es/Cascader/filter.js +92 -61
- package/es/Cascader/index.js +13 -18
- package/es/Cascader/styles/index.js +3 -4
- package/es/Checkbox/CheckItem.js +168 -154
- package/es/Checkbox/Checkbox.js +2 -3
- package/es/Checkbox/Group.js +106 -85
- package/es/Checkbox/context.js +12 -10
- package/es/Checkbox/index.js +14 -21
- package/es/Checkbox/styles/index.js +3 -4
- package/es/DataList/BaseItem.js +39 -21
- package/es/DataList/Extra.js +33 -17
- package/es/DataList/List.js +166 -140
- package/es/DataList/Meta.js +109 -74
- package/es/DataList/Pagination.js +9 -10
- package/es/DataList/index.js +13 -19
- package/es/DataList/styles/index.js +3 -4
- package/es/DatePicker/Container.js +468 -449
- package/es/DatePicker/Day.js +265 -258
- package/es/DatePicker/Icon.js +34 -20
- package/es/DatePicker/Month.js +101 -79
- package/es/DatePicker/Picker.js +110 -83
- package/es/DatePicker/Quick.js +52 -39
- package/es/DatePicker/Range.js +241 -192
- package/es/DatePicker/Text.js +103 -91
- package/es/DatePicker/Time.js +165 -147
- package/es/DatePicker/TimeScroll.js +148 -116
- package/es/DatePicker/Year.js +74 -53
- package/es/DatePicker/index.js +16 -18
- package/es/DatePicker/paramUtils.js +92 -58
- package/es/DatePicker/styles/index.js +3 -4
- package/es/DatePicker/utils.js +189 -198
- package/es/DatePicker/value.js +139 -98
- package/es/Datum/Form.js +333 -282
- package/es/Datum/List.js +319 -201
- package/es/Datum/Tree.js +298 -239
- package/es/Datum/hoc.js +104 -69
- package/es/Datum/index.js +7 -8
- package/es/Datum/types.js +20 -25
- package/es/Divider/index.js +50 -32
- package/es/Divider/styles/index.js +3 -4
- package/es/Drawer/index.js +14 -9
- package/es/Dropdown/Item.js +56 -43
- package/es/Dropdown/index.js +273 -259
- package/es/Dropdown/styles/index.js +3 -4
- package/es/EditableArea/EditableArea.js +157 -136
- package/es/EditableArea/index.js +8 -15
- package/es/EditableArea/styles/index.js +3 -4
- package/es/Form/Block.js +83 -57
- package/es/Form/BlockField.js +32 -17
- package/es/Form/Field.js +59 -35
- package/es/Form/FieldError.js +27 -21
- package/es/Form/FieldSet.js +214 -156
- package/es/Form/Flow.js +51 -32
- package/es/Form/Form.js +181 -144
- package/es/Form/Item.js +181 -166
- package/es/Form/Loop.js +202 -146
- package/es/Form/formButton.js +58 -42
- package/es/Form/formContext.js +104 -95
- package/es/Form/index.d.ts +1 -0
- package/es/Form/index.js +40 -45
- package/es/Form/inputable.js +368 -292
- package/es/Form/mode.js +15 -9
- package/es/Form/styles/index.js +4 -5
- package/es/Gap/index.js +71 -47
- package/es/Gap/styles/index.js +3 -4
- package/es/Gap/support.js +11 -14
- package/es/Grid/index.js +88 -58
- package/es/Grid/utils.js +57 -58
- package/es/Icon/Icon.js +43 -42
- package/es/Icon/index.js +39 -22
- package/es/Icon/styles/index.js +3 -4
- package/es/Image/Gallery.js +128 -113
- package/es/Image/Group.js +60 -36
- package/es/Image/Image.js +227 -153
- package/es/Image/Magnify.js +123 -94
- package/es/Image/events.js +29 -26
- package/es/Image/index.js +6 -9
- package/es/Image/styles/index.js +3 -4
- package/es/Input/Group.js +17 -11
- package/es/Input/Input.js +158 -134
- package/es/Input/Number.js +199 -175
- package/es/Input/Password.js +54 -31
- package/es/Input/clear.js +41 -25
- package/es/Input/index.js +23 -35
- package/es/Input/styles/index.js +3 -4
- package/es/Lazyload/index.js +63 -42
- package/es/Lazyload/styles/index.js +3 -4
- package/es/Menu/Item.js +275 -236
- package/es/Menu/List.js +75 -67
- package/es/Menu/Root.js +372 -334
- package/es/Menu/context.js +18 -12
- package/es/Menu/index.js +3 -5
- package/es/Menu/styles/index.js +3 -4
- package/es/Message/Container.js +155 -119
- package/es/Message/index.js +42 -30
- package/es/Message/messager.js +29 -33
- package/es/Message/styles/index.js +3 -4
- package/es/Modal/Modal.js +80 -60
- package/es/Modal/Panel.js +258 -234
- package/es/Modal/context.js +15 -15
- package/es/Modal/events.js +213 -182
- package/es/Modal/index.js +12 -14
- package/es/Modal/styles/index.js +3 -4
- package/es/Pagination/Item.js +46 -32
- package/es/Pagination/Jumper.js +79 -66
- package/es/Pagination/Links.js +110 -82
- package/es/Pagination/Next.js +52 -31
- package/es/Pagination/PageSizeList.js +57 -40
- package/es/Pagination/Pagination.js +78 -54
- package/es/Pagination/Prev.js +49 -30
- package/es/Pagination/Simple.js +32 -18
- package/es/Pagination/index.js +68 -41
- package/es/Pagination/styles/index.js +3 -4
- package/es/Popover/Confirm.js +107 -64
- package/es/Popover/Panel.js +284 -231
- package/es/Popover/context.js +15 -12
- package/es/Popover/events.js +80 -86
- package/es/Popover/index.js +12 -14
- package/es/Popover/styles/index.js +3 -4
- package/es/Progress/Circle.js +70 -59
- package/es/Progress/Line.js +51 -39
- package/es/Progress/Popup.js +42 -24
- package/es/Progress/analyzeColor.js +18 -9
- package/es/Progress/index.js +13 -15
- package/es/Progress/styles/index.js +3 -4
- package/es/Radio/Group.js +105 -94
- package/es/Radio/Radio.js +2 -3
- package/es/Radio/index.js +15 -17
- package/es/Radio/styles/index.js +1 -1
- package/es/Rate/Rate.js +216 -167
- package/es/Rate/index.js +17 -10
- package/es/Rate/styles/index.js +3 -4
- package/es/Rule/convert.js +48 -57
- package/es/Rule/index.js +63 -40
- package/es/Rule/length.js +53 -38
- package/es/Rule/regExp.js +23 -14
- package/es/Rule/required.js +26 -18
- package/es/Rule/styles/index.js +1 -1
- package/es/Rule/type.js +26 -18
- package/es/Scroll/Bar.js +145 -117
- package/es/Scroll/Scroll.js +277 -217
- package/es/Scroll/context.js +20 -13
- package/es/Scroll/fixedLength.js +33 -24
- package/es/Scroll/index.js +89 -55
- package/es/Scroll/styles/index.js +3 -4
- package/es/Select/BoxList.js +218 -189
- package/es/Select/BoxOption.js +64 -38
- package/es/Select/FlexBox.js +107 -75
- package/es/Select/FlexResult.js +65 -49
- package/es/Select/Input.js +137 -113
- package/es/Select/More.js +124 -121
- package/es/Select/Option.js +73 -52
- package/es/Select/OptionList.js +236 -200
- package/es/Select/OptionTree.js +111 -96
- package/es/Select/Result.js +297 -271
- package/es/Select/Select.js +517 -491
- package/es/Select/filter.js +221 -148
- package/es/Select/group.js +74 -45
- package/es/Select/index.js +32 -31
- package/es/Select/styles/index.js +3 -4
- package/es/Slider/Container.js +145 -132
- package/es/Slider/Indicator.js +28 -13
- package/es/Slider/Slider.js +132 -103
- package/es/Slider/index.js +5 -8
- package/es/Slider/styles/index.js +3 -4
- package/es/Slider/utils.js +26 -30
- package/es/Spin/Multiple.js +153 -109
- package/es/Spin/Simple.js +33 -22
- package/es/Spin/Spin.js +29 -29
- package/es/Spin/index.js +66 -84
- package/es/Spin/styles/index.js +27 -30
- package/es/Sticky/context.js +12 -10
- package/es/Sticky/index.js +255 -194
- package/es/Sticky/styles/index.js +1 -1
- package/es/Switch/Switch.js +2 -3
- package/es/Switch/index.js +8 -14
- package/es/Table/Checkbox.js +68 -39
- package/es/Table/CheckboxAll.js +121 -64
- package/es/Table/Colgroup.js +72 -47
- package/es/Table/Expand.js +63 -43
- package/es/Table/SeperateTable.js +594 -444
- package/es/Table/SimpleTable.js +215 -136
- package/es/Table/Sorter.js +83 -62
- package/es/Table/Table.js +157 -157
- package/es/Table/Tbody.js +240 -176
- package/es/Table/Td.js +169 -130
- package/es/Table/Thead.js +206 -177
- package/es/Table/Tr.js +249 -205
- package/es/Table/TreeExpand.js +151 -116
- package/es/Table/context.js +15 -15
- package/es/Table/fixedAuto.js +82 -59
- package/es/Table/index.js +309 -228
- package/es/Table/resizable.js +89 -56
- package/es/Table/select.js +238 -215
- package/es/Table/styles/index.js +3 -4
- package/es/Tabs/Header.js +203 -160
- package/es/Tabs/Link.js +46 -28
- package/es/Tabs/Panel.js +49 -33
- package/es/Tabs/Tab.js +97 -79
- package/es/Tabs/Tabs.js +211 -177
- package/es/Tabs/Wrapper.js +37 -17
- package/es/Tabs/index.js +7 -10
- package/es/Tabs/styles/index.js +3 -4
- package/es/Tag/Input.js +70 -54
- package/es/Tag/Tag.js +198 -156
- package/es/Tag/index.js +5 -8
- package/es/Tag/styles/index.js +3 -4
- package/es/Textarea/Textarea.js +139 -118
- package/es/Textarea/index.js +10 -19
- package/es/Tooltip/Container.js +140 -127
- package/es/Tooltip/events.js +49 -55
- package/es/Tooltip/index.js +5 -8
- package/es/Tooltip/styles/index.js +3 -4
- package/es/Transfer/Card.js +212 -177
- package/es/Transfer/Transfer.js +160 -153
- package/es/Transfer/btns.js +97 -80
- package/es/Transfer/context.js +2 -3
- package/es/Transfer/filter.js +65 -35
- package/es/Transfer/index.js +9 -13
- package/es/Transfer/item.js +66 -41
- package/es/Transfer/select.js +15 -16
- package/es/Transfer/styles/index.js +3 -4
- package/es/Tree/Checkbox.js +72 -50
- package/es/Tree/Content.js +136 -95
- package/es/Tree/List.js +82 -53
- package/es/Tree/Node.js +237 -202
- package/es/Tree/Root.js +23 -19
- package/es/Tree/Tree.js +262 -197
- package/es/Tree/index.js +6 -9
- package/es/Tree/styles/index.js +3 -4
- package/es/Tree/toggle.js +89 -51
- package/es/TreeSelect/Input.js +73 -60
- package/es/TreeSelect/Result.js +213 -181
- package/es/TreeSelect/TreeSelect.js +327 -312
- package/es/TreeSelect/datum.js +56 -44
- package/es/TreeSelect/filter.js +134 -96
- package/es/TreeSelect/index.js +15 -23
- package/es/TreeSelect/styles/index.js +3 -4
- package/es/TreeSelect/tiled.js +143 -106
- package/es/Upload/Dragger.js +63 -39
- package/es/Upload/Drop.js +79 -57
- package/es/Upload/File.js +61 -48
- package/es/Upload/FileInput.js +53 -40
- package/es/Upload/Image.js +158 -115
- package/es/Upload/ImageFile.js +63 -43
- package/es/Upload/ImageResult.js +139 -114
- package/es/Upload/Progress.js +117 -105
- package/es/Upload/RemoveConfirm.js +58 -42
- package/es/Upload/Result.js +73 -58
- package/es/Upload/Upload.js +649 -490
- package/es/Upload/accept.js +33 -13
- package/es/Upload/context.js +12 -10
- package/es/Upload/index.js +16 -20
- package/es/Upload/request.js +48 -46
- package/es/Upload/styles/index.js +3 -4
- package/es/component.js +45 -24
- package/es/config.js +27 -19
- package/es/context/implementation.js +132 -94
- package/es/context/index.js +3 -4
- package/es/hoc/coin.js +118 -81
- package/es/hoc/config.js +31 -17
- package/es/hoc/delay.js +99 -55
- package/es/hoc/draggable.js +90 -80
- package/es/hoc/fetch.js +56 -33
- package/es/hoc/hidable.js +119 -98
- package/es/hoc/inputBorder.js +158 -158
- package/es/hoc/moveable.js +124 -96
- package/es/hoc/pagable.js +74 -55
- package/es/hoc/resizable.js +132 -100
- package/es/hoc/styles/index.js +7 -8
- package/es/hoc/trim.js +54 -32
- package/es/icons/Caret.js +14 -15
- package/es/icons/index.js +31 -85
- package/es/index.d.ts +1 -1
- package/es/index.js +58 -57
- package/es/locale/en_US.js +9 -30
- package/es/locale/index.js +13 -14
- package/es/locale/zh-CN.js +9 -17
- package/es/styles/expose.js +3 -4
- package/es/styles/index.js +1 -1
- package/es/utils/accept.js +15 -12
- package/es/utils/classname.js +23 -12
- package/es/utils/cleanProps.js +9 -21
- package/es/utils/clone.js +34 -27
- package/es/utils/color.js +310 -276
- package/es/utils/css-accessors.js +94 -45
- package/es/utils/dom/detect.js +29 -29
- package/es/utils/dom/document.js +23 -19
- package/es/utils/dom/element.js +139 -105
- package/es/utils/dom/getDataset.js +9 -9
- package/es/utils/dom/isDOMElement.js +3 -5
- package/es/utils/dom/normalizeWheel.js +32 -28
- package/es/utils/dom/popContainer.js +12 -13
- package/es/utils/dom/popover.js +79 -59
- package/es/utils/dom/ready.js +5 -6
- package/es/utils/dom/translate.js +10 -12
- package/es/utils/errors.js +47 -28
- package/es/utils/expose.js +97 -58
- package/es/utils/flat.js +122 -107
- package/es/utils/func.js +38 -20
- package/es/utils/hash.js +24 -20
- package/es/utils/index.js +24 -49
- package/es/utils/is.js +91 -70
- package/es/utils/lazyload.js +104 -86
- package/es/utils/notification.js +34 -20
- package/es/utils/numbers.js +61 -51
- package/es/utils/objects.js +221 -140
- package/es/utils/proptypes.js +21 -34
- package/es/utils/shallowEqual.js +46 -42
- package/es/utils/strings.js +50 -32
- package/es/utils/transform.js +24 -9
- package/es/utils/tree.js +78 -63
- package/es/utils/uid.js +14 -17
- package/es/utils/validate/index.js +71 -50
- package/es/utils/validate/isJson.js +7 -10
- package/es/utils/validate/nullable.js +10 -9
- package/es/utils/validate/range.js +22 -19
- package/es/utils/validate/rangeLength.js +19 -16
- package/es/utils/validate/regExp.js +10 -10
- package/es/utils/validate/required.js +11 -8
- package/es/utils/validate/type.js +56 -59
- package/es/utils/vars-inject.js +3420 -4248
- package/lib/DatePicker/utils.js +1 -1
- package/lib/Form/Field.js +8 -4
- package/lib/Form/Form.js +3 -0
- package/lib/Form/Item.js +1 -1
- package/lib/Form/index.d.ts +1 -0
- package/lib/Form/inputable.js +1 -1
- package/lib/Pagination/Jumper.js +3 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +3 -2
package/es/Table/SimpleTable.js
CHANGED
|
@@ -1,162 +1,243 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { PureComponent } from '../component';
|
|
8
|
+
import { tableClass } from './styles';
|
|
9
|
+
import { range, split } from '../utils/numbers';
|
|
10
|
+
import Colgroup from './Colgroup';
|
|
11
|
+
import Tbody from './Tbody';
|
|
12
|
+
import Thead from './Thead';
|
|
13
|
+
import { compareColumns } from '../utils/shallowEqual';
|
|
14
|
+
import Sticky from '../Sticky';
|
|
15
|
+
import { addResizeObserver } from '../utils/dom/element';
|
|
12
16
|
|
|
13
17
|
function setScrollLeft(target, scrollLeft) {
|
|
14
|
-
if (target && target.scrollLeft !== scrollLeft) target.scrollLeft = scrollLeft
|
|
18
|
+
if (target && target.scrollLeft !== scrollLeft) target.scrollLeft = scrollLeft;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
var SimpleTable =
|
|
22
|
+
/*#__PURE__*/
|
|
23
|
+
function (_PureComponent) {
|
|
24
|
+
_inheritsLoose(SimpleTable, _PureComponent);
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
function SimpleTable(props) {
|
|
27
|
+
var _this;
|
|
28
|
+
|
|
29
|
+
_this = _PureComponent.call(this, props) || this;
|
|
30
|
+
_this.state = {
|
|
22
31
|
colgroup: undefined,
|
|
23
32
|
scrollAble: false,
|
|
24
|
-
resize: false
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
resize: false
|
|
34
|
+
};
|
|
35
|
+
_this.handleSortChange = _this.handleSortChange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
36
|
+
_this.bindHeader = _this.bindElement.bind(_assertThisInitialized(_assertThisInitialized(_this)), 'header');
|
|
37
|
+
_this.bindBody = _this.bindElement.bind(_assertThisInitialized(_assertThisInitialized(_this)), 'body');
|
|
38
|
+
_this.handleScroll = _this.handleScroll.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
39
|
+
_this.handleColgroup = _this.handleColgroup.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
40
|
+
_this.resetColGroup = _this.resetColGroup.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
41
|
+
return _this;
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
var _proto = SimpleTable.prototype;
|
|
45
|
+
|
|
46
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
47
|
+
this.scrollCheck();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
51
|
+
this.scrollCheck();
|
|
52
|
+
var resize = prevProps.data.length === 0 && this.props.data.length;
|
|
53
|
+
var shouldResetColgroup = this.props.dataChangeResize && this.props.data !== prevProps.data;
|
|
37
54
|
|
|
38
|
-
componentDidUpdate(prevProps) {
|
|
39
|
-
this.scrollCheck()
|
|
40
|
-
const resize = prevProps.data.length === 0 && this.props.data.length
|
|
41
|
-
const shouldResetColgroup = this.props.dataChangeResize && this.props.data !== prevProps.data
|
|
42
55
|
if (resize || shouldResetColgroup || !compareColumns(prevProps.columns, this.props.columns)) {
|
|
43
|
-
this.setState({
|
|
56
|
+
this.setState({
|
|
57
|
+
colgroup: undefined,
|
|
58
|
+
resize: true
|
|
59
|
+
});
|
|
44
60
|
}
|
|
45
|
-
}
|
|
61
|
+
};
|
|
46
62
|
|
|
47
|
-
componentWillUnmount() {
|
|
48
|
-
if (this.body) this.body.removeEventListener('wheel', this.handleScroll)
|
|
49
|
-
if (this.removeReiszeObserver) this.removeReiszeObserver()
|
|
50
|
-
}
|
|
63
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
64
|
+
if (this.body) this.body.removeEventListener('wheel', this.handleScroll);
|
|
65
|
+
if (this.removeReiszeObserver) this.removeReiszeObserver();
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_proto.bindElement = function bindElement(key, el) {
|
|
69
|
+
this[key] = el; // this.body will be undefined on componentDidMount when columns length is 0
|
|
51
70
|
|
|
52
|
-
bindElement(key, el) {
|
|
53
|
-
this[key] = el
|
|
54
|
-
// this.body will be undefined on componentDidMount when columns length is 0
|
|
55
71
|
if (key === 'body' && el) {
|
|
56
|
-
el.addEventListener('wheel', this.handleScroll, {
|
|
57
|
-
|
|
72
|
+
el.addEventListener('wheel', this.handleScroll, {
|
|
73
|
+
passive: false
|
|
74
|
+
});
|
|
75
|
+
this.removeReiszeObserver = addResizeObserver(el, this.resetColGroup, {
|
|
76
|
+
direction: 'x'
|
|
77
|
+
});
|
|
58
78
|
}
|
|
59
|
-
}
|
|
79
|
+
};
|
|
60
80
|
|
|
61
|
-
resetColGroup() {
|
|
62
|
-
this.setState({
|
|
63
|
-
|
|
81
|
+
_proto.resetColGroup = function resetColGroup() {
|
|
82
|
+
this.setState({
|
|
83
|
+
colgroup: undefined,
|
|
84
|
+
resize: true
|
|
85
|
+
});
|
|
86
|
+
};
|
|
64
87
|
|
|
65
|
-
scrollCheck() {
|
|
66
|
-
|
|
67
|
-
if (!this.body) return
|
|
68
|
-
|
|
69
|
-
if (scrollAble !== overHeight) this.setState({
|
|
70
|
-
|
|
88
|
+
_proto.scrollCheck = function scrollCheck() {
|
|
89
|
+
var scrollAble = this.state.scrollAble;
|
|
90
|
+
if (!this.body) return;
|
|
91
|
+
var overHeight = this.body.scrollHeight > this.body.clientHeight;
|
|
92
|
+
if (scrollAble !== overHeight) this.setState({
|
|
93
|
+
scrollAble: overHeight
|
|
94
|
+
});
|
|
95
|
+
};
|
|
71
96
|
|
|
72
|
-
handleSortChange(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
97
|
+
_proto.handleSortChange = function handleSortChange() {
|
|
98
|
+
var _this$props;
|
|
99
|
+
|
|
100
|
+
if (this.body) this.body.scrollTop = 0;
|
|
101
|
+
|
|
102
|
+
(_this$props = this.props).onSortChange.apply(_this$props, arguments);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
_proto.handleColgroup = function handleColgroup(tds) {
|
|
106
|
+
var columns = this.props.columns;
|
|
107
|
+
var colgroup = [];
|
|
108
|
+
|
|
109
|
+
var _loop = function _loop(i, count) {
|
|
110
|
+
var width = tds[i].offsetWidth;
|
|
111
|
+
var colSpan = parseInt(tds[i].getAttribute('colspan'), 10);
|
|
76
112
|
|
|
77
|
-
handleColgroup(tds) {
|
|
78
|
-
const { columns } = this.props
|
|
79
|
-
const colgroup = []
|
|
80
|
-
for (let i = 0, count = tds.length; i < count; i++) {
|
|
81
|
-
const width = tds[i].offsetWidth
|
|
82
|
-
const colSpan = parseInt(tds[i].getAttribute('colspan'), 10)
|
|
83
113
|
if (colSpan > 1) {
|
|
84
|
-
split(width, range(colSpan).map(
|
|
114
|
+
split(width, range(colSpan).map(function (j) {
|
|
115
|
+
return columns[i + j].width;
|
|
116
|
+
})).forEach(function (w) {
|
|
117
|
+
return colgroup.push(w);
|
|
118
|
+
});
|
|
85
119
|
} else {
|
|
86
|
-
colgroup.push(width)
|
|
120
|
+
colgroup.push(width);
|
|
87
121
|
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
for (var i = 0, count = tds.length; i < count; i++) {
|
|
125
|
+
_loop(i, count);
|
|
88
126
|
}
|
|
89
|
-
this.setState({ colgroup, resize: false })
|
|
90
|
-
}
|
|
91
127
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
128
|
+
this.setState({
|
|
129
|
+
colgroup: colgroup,
|
|
130
|
+
resize: false
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
_proto.handleScroll = function handleScroll(_ref) {
|
|
135
|
+
var currentTarget = _ref.currentTarget;
|
|
136
|
+
var scrollLeft = currentTarget.scrollLeft;
|
|
137
|
+
setScrollLeft(this.header, scrollLeft);
|
|
138
|
+
setScrollLeft(this.body, scrollLeft);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
_proto.renderHeader = function renderHeader() {
|
|
142
|
+
var _this$props2 = this.props,
|
|
143
|
+
columns = _this$props2.columns,
|
|
144
|
+
width = _this$props2.width,
|
|
145
|
+
data = _this$props2.data,
|
|
146
|
+
onResize = _this$props2.onResize,
|
|
147
|
+
columnResizable = _this$props2.columnResizable,
|
|
148
|
+
sticky = _this$props2.sticky;
|
|
149
|
+
var _this$state = this.state,
|
|
150
|
+
colgroup = _this$state.colgroup,
|
|
151
|
+
scrollAble = _this$state.scrollAble;
|
|
152
|
+
var inner = React.createElement("table", {
|
|
153
|
+
style: {
|
|
154
|
+
width: width
|
|
155
|
+
}
|
|
156
|
+
}, React.createElement(Colgroup, {
|
|
157
|
+
colgroup: colgroup,
|
|
158
|
+
columns: columns,
|
|
159
|
+
resizable: columnResizable
|
|
160
|
+
}), React.createElement(Thead, _extends({}, this.props, {
|
|
161
|
+
colgroup: colgroup,
|
|
162
|
+
onSortChange: this.handleSortChange,
|
|
163
|
+
onColChange: onResize
|
|
164
|
+
})));
|
|
165
|
+
var empty = data.length === 0;
|
|
166
|
+
var headerStyle = {};
|
|
167
|
+
if (!empty) headerStyle.overflowY = scrollAble ? 'scroll' : 'hidden';
|
|
168
|
+
var header = React.createElement("div", {
|
|
169
|
+
key: "head",
|
|
170
|
+
style: headerStyle,
|
|
171
|
+
className: tableClass('head', 'simple-head', empty && 'empty-head'),
|
|
172
|
+
ref: this.bindHeader
|
|
173
|
+
}, inner);
|
|
97
174
|
|
|
98
|
-
renderHeader() {
|
|
99
|
-
const { columns, width, data, onResize, columnResizable, sticky } = this.props
|
|
100
|
-
const { colgroup, scrollAble } = this.state
|
|
101
|
-
const inner = (
|
|
102
|
-
<table style={{ width }}>
|
|
103
|
-
<Colgroup colgroup={colgroup} columns={columns} resizable={columnResizable} />
|
|
104
|
-
<Thead {...this.props} colgroup={colgroup} onSortChange={this.handleSortChange} onColChange={onResize} />
|
|
105
|
-
</table>
|
|
106
|
-
)
|
|
107
|
-
const empty = data.length === 0
|
|
108
|
-
const headerStyle = {}
|
|
109
|
-
if (!empty) headerStyle.overflowY = scrollAble ? 'scroll' : 'hidden'
|
|
110
|
-
|
|
111
|
-
const header = (
|
|
112
|
-
<div
|
|
113
|
-
key="head"
|
|
114
|
-
style={headerStyle}
|
|
115
|
-
className={tableClass('head', 'simple-head', empty && 'empty-head')}
|
|
116
|
-
ref={this.bindHeader}
|
|
117
|
-
>
|
|
118
|
-
{inner}
|
|
119
|
-
</div>
|
|
120
|
-
)
|
|
121
175
|
if (sticky) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
)
|
|
176
|
+
var stickyProps = Object.assign({
|
|
177
|
+
top: 0
|
|
178
|
+
}, sticky);
|
|
179
|
+
return React.createElement(Sticky, _extends({}, stickyProps, {
|
|
180
|
+
key: "head"
|
|
181
|
+
}), header);
|
|
128
182
|
}
|
|
129
|
-
return header
|
|
130
|
-
}
|
|
131
183
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const { colgroup, resize } = this.state
|
|
135
|
-
const minWidthSup = columns.find(d => d.minWidth)
|
|
136
|
-
return (
|
|
137
|
-
<div key="body" className={tableClass('simple-body')} ref={this.bindBody} onScroll={this.handleScroll}>
|
|
138
|
-
<table style={{ width }} className={tableClass(!colgroup && minWidthSup && 'init')}>
|
|
139
|
-
<Colgroup colgroup={colgroup} columns={columns} resizable={columnResizable} />
|
|
140
|
-
<Tbody
|
|
141
|
-
colgroup={colgroup}
|
|
142
|
-
lazy={false}
|
|
143
|
-
index={0}
|
|
144
|
-
columns={columns}
|
|
145
|
-
onBodyRender={this.handleColgroup}
|
|
146
|
-
resize={resize}
|
|
147
|
-
{...others}
|
|
148
|
-
/>
|
|
149
|
-
</table>
|
|
150
|
-
</div>
|
|
151
|
-
)
|
|
152
|
-
}
|
|
184
|
+
return header;
|
|
185
|
+
};
|
|
153
186
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
187
|
+
_proto.renderBody = function renderBody() {
|
|
188
|
+
var _this$props3 = this.props,
|
|
189
|
+
columns = _this$props3.columns,
|
|
190
|
+
width = _this$props3.width,
|
|
191
|
+
fixed = _this$props3.fixed,
|
|
192
|
+
columnResizable = _this$props3.columnResizable,
|
|
193
|
+
others = _objectWithoutPropertiesLoose(_this$props3, ["columns", "width", "fixed", "columnResizable"]);
|
|
194
|
+
|
|
195
|
+
var _this$state2 = this.state,
|
|
196
|
+
colgroup = _this$state2.colgroup,
|
|
197
|
+
resize = _this$state2.resize;
|
|
198
|
+
var minWidthSup = columns.find(function (d) {
|
|
199
|
+
return d.minWidth;
|
|
200
|
+
});
|
|
201
|
+
return React.createElement("div", {
|
|
202
|
+
key: "body",
|
|
203
|
+
className: tableClass('simple-body'),
|
|
204
|
+
ref: this.bindBody,
|
|
205
|
+
onScroll: this.handleScroll
|
|
206
|
+
}, React.createElement("table", {
|
|
207
|
+
style: {
|
|
208
|
+
width: width
|
|
209
|
+
},
|
|
210
|
+
className: tableClass(!colgroup && minWidthSup && 'init')
|
|
211
|
+
}, React.createElement(Colgroup, {
|
|
212
|
+
colgroup: colgroup,
|
|
213
|
+
columns: columns,
|
|
214
|
+
resizable: columnResizable
|
|
215
|
+
}), React.createElement(Tbody, _extends({
|
|
216
|
+
colgroup: colgroup,
|
|
217
|
+
lazy: false,
|
|
218
|
+
index: 0,
|
|
219
|
+
columns: columns,
|
|
220
|
+
onBodyRender: this.handleColgroup,
|
|
221
|
+
resize: resize
|
|
222
|
+
}, others))));
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
_proto.render = function render() {
|
|
226
|
+
var _this$props4 = this.props,
|
|
227
|
+
columns = _this$props4.columns,
|
|
228
|
+
width = _this$props4.width,
|
|
229
|
+
children = _this$props4.children,
|
|
230
|
+
hideHeader = _this$props4.hideHeader;
|
|
231
|
+
if (!columns || columns.length === 0) return React.createElement("table", {
|
|
232
|
+
style: {
|
|
233
|
+
width: width
|
|
234
|
+
}
|
|
235
|
+
}, children);
|
|
236
|
+
return [hideHeader ? null : this.renderHeader(), this.renderBody(), children];
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
return SimpleTable;
|
|
240
|
+
}(PureComponent);
|
|
160
241
|
|
|
161
242
|
SimpleTable.propTypes = {
|
|
162
243
|
columns: PropTypes.array,
|
|
@@ -169,12 +250,10 @@ SimpleTable.propTypes = {
|
|
|
169
250
|
dataChangeResize: PropTypes.bool,
|
|
170
251
|
columnResizable: PropTypes.bool,
|
|
171
252
|
sticky: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
|
|
172
|
-
hideHeader: PropTypes.bool
|
|
173
|
-
}
|
|
174
|
-
|
|
253
|
+
hideHeader: PropTypes.bool
|
|
254
|
+
};
|
|
175
255
|
SimpleTable.defaultProps = {
|
|
176
256
|
data: undefined,
|
|
177
|
-
width: undefined
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export default SimpleTable
|
|
257
|
+
width: undefined
|
|
258
|
+
};
|
|
259
|
+
export default SimpleTable;
|
package/es/Table/Sorter.js
CHANGED
|
@@ -1,78 +1,99 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
3
|
+
import React, { PureComponent } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { tableClass } from './styles';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.handleDesc = this.handleDesc.bind(this)
|
|
10
|
-
}
|
|
7
|
+
var Sorter =
|
|
8
|
+
/*#__PURE__*/
|
|
9
|
+
function (_PureComponent) {
|
|
10
|
+
_inheritsLoose(Sorter, _PureComponent);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
function Sorter(props) {
|
|
13
|
+
var _this;
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
_this = _PureComponent.call(this, props) || this;
|
|
16
|
+
_this.handleAsc = _this.handleAsc.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
17
|
+
_this.handleDesc = _this.handleDesc.bind(_assertThisInitialized(_assertThisInitialized(_this)));
|
|
18
|
+
return _this;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
const { defaultOrder, current, index } = this.props
|
|
22
|
-
if (current.length !== 1) return
|
|
23
|
-
const item = current[0]
|
|
24
|
-
const changed = index === item.index && defaultOrder === item.order
|
|
25
|
-
if (defaultOrder && !changed && !item.manual) this.handleChange(defaultOrder, false)
|
|
26
|
-
}
|
|
21
|
+
var _proto = Sorter.prototype;
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const isCancel = !!item && order === item.order
|
|
32
|
-
const finalOrder = isCancel ? undefined : order
|
|
33
|
-
onChange(finalOrder, sorter, index, order, manual)
|
|
34
|
-
}
|
|
23
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
24
|
+
this.defaultSorterOrder();
|
|
25
|
+
};
|
|
35
26
|
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
}
|
|
27
|
+
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
28
|
+
this.defaultSorterOrder();
|
|
29
|
+
};
|
|
39
30
|
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
|
|
31
|
+
_proto.defaultSorterOrder = function defaultSorterOrder() {
|
|
32
|
+
var _this$props = this.props,
|
|
33
|
+
defaultOrder = _this$props.defaultOrder,
|
|
34
|
+
current = _this$props.current,
|
|
35
|
+
index = _this$props.index;
|
|
36
|
+
if (current.length !== 1) return;
|
|
37
|
+
var item = current[0];
|
|
38
|
+
var changed = index === item.index && defaultOrder === item.order;
|
|
39
|
+
if (defaultOrder && !changed && !item.manual) this.handleChange(defaultOrder, false);
|
|
40
|
+
};
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
_proto.handleChange = function handleChange(order, manual) {
|
|
43
|
+
if (manual === void 0) {
|
|
44
|
+
manual = true;
|
|
45
|
+
}
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
47
|
+
var _this$props2 = this.props,
|
|
48
|
+
sorter = _this$props2.sorter,
|
|
49
|
+
index = _this$props2.index,
|
|
50
|
+
onChange = _this$props2.onChange,
|
|
51
|
+
current = _this$props2.current;
|
|
52
|
+
var item = current.find(function (v) {
|
|
53
|
+
return v.index === index;
|
|
54
|
+
});
|
|
55
|
+
var isCancel = !!item && order === item.order;
|
|
56
|
+
var finalOrder = isCancel ? undefined : order;
|
|
57
|
+
onChange(finalOrder, sorter, index, order, manual);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
_proto.handleAsc = function handleAsc() {
|
|
61
|
+
this.handleChange('asc');
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
_proto.handleDesc = function handleDesc() {
|
|
65
|
+
this.handleChange('desc');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_proto.render = function render() {
|
|
69
|
+
var _this$props3 = this.props,
|
|
70
|
+
current = _this$props3.current,
|
|
71
|
+
index = _this$props3.index;
|
|
72
|
+
var item = current.find(function (v) {
|
|
73
|
+
return v.index === index;
|
|
74
|
+
});
|
|
75
|
+
var active = !!item;
|
|
76
|
+
return React.createElement("div", {
|
|
77
|
+
className: tableClass('sorter-container')
|
|
78
|
+
}, React.createElement("a", {
|
|
79
|
+
key: "asc",
|
|
80
|
+
className: tableClass(active && item.order === 'asc' && 'sorter-active', 'sorter-asc'),
|
|
81
|
+
onClick: this.handleAsc
|
|
82
|
+
}, "\xA0"), React.createElement("a", {
|
|
83
|
+
key: "desc",
|
|
84
|
+
className: tableClass(active && item.order === 'desc' && 'sorter-active', 'sorter-desc'),
|
|
85
|
+
onClick: this.handleDesc
|
|
86
|
+
}, "\xA0"));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return Sorter;
|
|
90
|
+
}(PureComponent);
|
|
69
91
|
|
|
70
92
|
Sorter.propTypes = {
|
|
71
93
|
current: PropTypes.array,
|
|
72
94
|
index: PropTypes.number.isRequired,
|
|
73
95
|
onChange: PropTypes.func.isRequired,
|
|
74
96
|
sorter: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.object]).isRequired,
|
|
75
|
-
defaultOrder: PropTypes.oneOf(['desc', 'asc'])
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default Sorter
|
|
97
|
+
defaultOrder: PropTypes.oneOf(['desc', 'asc'])
|
|
98
|
+
};
|
|
99
|
+
export default Sorter;
|