tntd 3.0.23 → 3.0.25
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/query-form/Field/Composition/FieldPopover.js +310 -0
- package/es/query-form/Field/Composition/FieldPopover.js.map +1 -0
- package/es/query-form/Field/Composition/FieldPopover.less +35 -0
- package/es/query-form/Field/Composition/Select.js +122 -0
- package/es/query-form/Field/Composition/Select.js.map +1 -0
- package/es/query-form/Field/Composition/index.js +248 -0
- package/es/query-form/Field/Composition/index.js.map +1 -0
- package/es/query-form/Field/Composition/index.less +118 -0
- package/es/query-form/Field/Composition/utils.js +153 -0
- package/es/query-form/Field/Composition/utils.js.map +1 -0
- package/es/query-form-v2/index.less +133 -0
- package/es/scroll-bar/Bar.js +56 -0
- package/es/scroll-bar/Bar.js.map +1 -0
- package/es/scroll-bar/Context.js +6 -0
- package/es/scroll-bar/Context.js.map +1 -0
- package/es/scroll-bar/ScrollBar.js +86 -0
- package/es/scroll-bar/ScrollBar.js.map +1 -0
- package/es/scroll-bar/Thumb.js +105 -0
- package/es/scroll-bar/Thumb.js.map +1 -0
- package/es/scroll-bar/index.js +3 -0
- package/es/scroll-bar/index.js.map +1 -0
- package/es/scroll-bar/scrollBar.less +59 -0
- package/es/scroll-bar/util.js +31 -0
- package/es/scroll-bar/util.js.map +1 -0
- package/es/table/table.js +7 -11
- package/es/table/table.js.map +1 -1
- package/es/tntd-virtual-tree/index.js +20 -6
- package/es/tntd-virtual-tree/index.js.map +1 -1
- package/es/tntd-virtual-tree/index.less +1 -2
- package/es/tntd-virtual-tree-select/index.js +4 -2
- package/es/tntd-virtual-tree-select/index.js.map +1 -1
- package/lib/query-form/Field/Composition/FieldPopover.d.ts +19 -0
- package/lib/query-form/Field/Composition/FieldPopover.d.ts.map +1 -0
- package/lib/query-form/Field/Composition/FieldPopover.js +345 -0
- package/lib/query-form/Field/Composition/FieldPopover.js.map +1 -0
- package/lib/query-form/Field/Composition/FieldPopover.less +35 -0
- package/lib/query-form/Field/Composition/Select.d.ts +4 -0
- package/lib/query-form/Field/Composition/Select.d.ts.map +1 -0
- package/lib/query-form/Field/Composition/Select.js +146 -0
- package/lib/query-form/Field/Composition/Select.js.map +1 -0
- package/lib/query-form/Field/Composition/index.d.ts +12 -0
- package/lib/query-form/Field/Composition/index.d.ts.map +1 -0
- package/lib/query-form/Field/Composition/index.js +294 -0
- package/lib/query-form/Field/Composition/index.js.map +1 -0
- package/lib/query-form/Field/Composition/index.less +118 -0
- package/lib/query-form/Field/Composition/utils.d.ts +21 -0
- package/lib/query-form/Field/Composition/utils.d.ts.map +1 -0
- package/lib/query-form/Field/Composition/utils.js +164 -0
- package/lib/query-form/Field/Composition/utils.js.map +1 -0
- package/lib/query-form-v2/Field/Checkbox.d.ts +8 -0
- package/lib/query-form-v2/Field/Checkbox.d.ts.map +1 -0
- package/lib/query-form-v2/Field/Checkbox.js +28 -0
- package/lib/query-form-v2/Field/Checkbox.js.map +1 -0
- package/lib/{upload/svg/UploadSVG.d.ts → query-form-v2/Field/Select.d.ts} +1 -1
- package/lib/query-form-v2/Field/Select.d.ts.map +1 -0
- package/lib/query-form-v2/Field/Select.js +80 -0
- package/lib/query-form-v2/Field/Select.js.map +1 -0
- package/lib/query-form-v2/Field/SelectInput.d.ts +4 -0
- package/lib/query-form-v2/Field/SelectInput.d.ts.map +1 -0
- package/lib/query-form-v2/Field/SelectInput.js +88 -0
- package/lib/query-form-v2/Field/SelectInput.js.map +1 -0
- package/lib/query-form-v2/Field/fieldsMap.d.ts +24 -0
- package/lib/query-form-v2/Field/fieldsMap.d.ts.map +1 -0
- package/lib/query-form-v2/Field/fieldsMap.js +35 -0
- package/lib/query-form-v2/Field/fieldsMap.js.map +1 -0
- package/lib/query-form-v2/Field/index.d.ts +14 -0
- package/lib/query-form-v2/Field/index.d.ts.map +1 -0
- package/lib/query-form-v2/Field/index.js +146 -0
- package/lib/query-form-v2/Field/index.js.map +1 -0
- package/lib/query-form-v2/createActions.d.ts +14 -0
- package/lib/query-form-v2/createActions.d.ts.map +1 -0
- package/lib/query-form-v2/createActions.js +54 -0
- package/lib/query-form-v2/createActions.js.map +1 -0
- package/lib/query-form-v2/index.d.ts +39 -0
- package/lib/query-form-v2/index.d.ts.map +1 -0
- package/lib/query-form-v2/index.js +391 -0
- package/lib/query-form-v2/index.js.map +1 -0
- package/lib/query-form-v2/index.less +133 -0
- package/lib/query-form-v2/useForm.d.ts +13 -0
- package/lib/query-form-v2/useForm.d.ts.map +1 -0
- package/lib/query-form-v2/useForm.js +13 -0
- package/lib/query-form-v2/useForm.js.map +1 -0
- package/lib/query-form-v3/Field/Checkbox.d.ts +8 -0
- package/lib/query-form-v3/Field/Checkbox.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Checkbox.js +28 -0
- package/lib/query-form-v3/Field/Checkbox.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts +19 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.js +381 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.less +35 -0
- package/lib/query-form-v3/Field/Composition/Select.d.ts +4 -0
- package/lib/query-form-v3/Field/Composition/Select.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/Select.js +131 -0
- package/lib/query-form-v3/Field/Composition/Select.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/index.d.ts +10 -0
- package/lib/query-form-v3/Field/Composition/index.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/index.js +255 -0
- package/lib/query-form-v3/Field/Composition/index.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/index.less +118 -0
- package/lib/query-form-v3/Field/Composition/utils.d.ts +22 -0
- package/lib/query-form-v3/Field/Composition/utils.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/utils.js +147 -0
- package/lib/query-form-v3/Field/Composition/utils.js.map +1 -0
- package/lib/query-form-v3/Field/Select.d.ts +4 -0
- package/lib/query-form-v3/Field/Select.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Select.js +80 -0
- package/lib/query-form-v3/Field/Select.js.map +1 -0
- package/lib/query-form-v3/Field/SelectInput.d.ts +4 -0
- package/lib/query-form-v3/Field/SelectInput.d.ts.map +1 -0
- package/lib/query-form-v3/Field/SelectInput.js +100 -0
- package/lib/query-form-v3/Field/SelectInput.js.map +1 -0
- package/lib/query-form-v3/Field/fieldsMap.d.ts +27 -0
- package/lib/query-form-v3/Field/fieldsMap.d.ts.map +1 -0
- package/lib/query-form-v3/Field/fieldsMap.js +35 -0
- package/lib/query-form-v3/Field/fieldsMap.js.map +1 -0
- package/lib/query-form-v3/Field/index.d.ts +14 -0
- package/lib/query-form-v3/Field/index.d.ts.map +1 -0
- package/lib/query-form-v3/Field/index.js +147 -0
- package/lib/query-form-v3/Field/index.js.map +1 -0
- package/lib/query-form-v3/createActions.d.ts +14 -0
- package/lib/query-form-v3/createActions.d.ts.map +1 -0
- package/lib/query-form-v3/createActions.js +54 -0
- package/lib/query-form-v3/createActions.js.map +1 -0
- package/lib/query-form-v3/index.d.ts +27 -0
- package/lib/query-form-v3/index.d.ts.map +1 -0
- package/lib/query-form-v3/index.js +206 -0
- package/lib/query-form-v3/index.js.map +1 -0
- package/lib/query-form-v3/index.less +91 -0
- package/lib/query-form-v3/useForm.d.ts +13 -0
- package/lib/query-form-v3/useForm.d.ts.map +1 -0
- package/lib/query-form-v3/useForm.js +13 -0
- package/lib/query-form-v3/useForm.js.map +1 -0
- package/lib/scroll-bar/Bar.d.ts +4 -0
- package/lib/scroll-bar/Bar.d.ts.map +1 -0
- package/lib/scroll-bar/Bar.js +91 -0
- package/lib/scroll-bar/Bar.js.map +1 -0
- package/lib/scroll-bar/Context.d.ts +7 -0
- package/lib/scroll-bar/Context.d.ts.map +1 -0
- package/lib/scroll-bar/Context.js +13 -0
- package/lib/scroll-bar/Context.js.map +1 -0
- package/lib/scroll-bar/ScrollBar.d.ts +4 -0
- package/lib/scroll-bar/ScrollBar.d.ts.map +1 -0
- package/lib/scroll-bar/ScrollBar.js +97 -0
- package/lib/scroll-bar/ScrollBar.js.map +1 -0
- package/lib/scroll-bar/Thumb.d.ts +3 -0
- package/lib/scroll-bar/Thumb.d.ts.map +1 -0
- package/lib/scroll-bar/Thumb.js +125 -0
- package/lib/scroll-bar/Thumb.js.map +1 -0
- package/lib/scroll-bar/index.d.ts +3 -0
- package/lib/scroll-bar/index.d.ts.map +1 -0
- package/lib/scroll-bar/index.js +10 -0
- package/lib/scroll-bar/index.js.map +1 -0
- package/lib/scroll-bar/scrollBar.less +59 -0
- package/lib/scroll-bar/util.d.ts +40 -0
- package/lib/scroll-bar/util.d.ts.map +1 -0
- package/lib/scroll-bar/util.js +39 -0
- package/lib/scroll-bar/util.js.map +1 -0
- package/lib/table/table.d.ts +1 -1
- package/lib/table/table.d.ts.map +1 -1
- package/lib/table/table.js +7 -14
- package/lib/table/table.js.map +1 -1
- package/lib/tntd-virtual-tree/index.d.ts +2 -1
- package/lib/tntd-virtual-tree/index.d.ts.map +1 -1
- package/lib/tntd-virtual-tree/index.js +20 -6
- package/lib/tntd-virtual-tree/index.js.map +1 -1
- package/lib/tntd-virtual-tree/index.less +1 -2
- package/lib/tntd-virtual-tree-select/index.d.ts +2 -1
- package/lib/tntd-virtual-tree-select/index.d.ts.map +1 -1
- package/lib/tntd-virtual-tree-select/index.js +5 -2
- package/lib/tntd-virtual-tree-select/index.js.map +1 -1
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.json +0 -1034
- package/CHANGELOG.md +0 -605
- package/es/checkbox/checkbox-group.js +0 -5
- package/es/checkbox/checkbox-group.js.map +0 -1
- package/es/radio/radio-group.js +0 -5
- package/es/radio/radio-group.js.map +0 -1
- package/es/steps/stepStyle/small.less +0 -5
- package/es/upload/svg/UploadSVG.js +0 -37
- package/es/upload/svg/UploadSVG.js.map +0 -1
- package/es/upload/upload.less +0 -108
- package/lib/checkbox/checkbox-group.d.ts +0 -8
- package/lib/checkbox/checkbox-group.d.ts.map +0 -1
- package/lib/checkbox/checkbox-group.js +0 -12
- package/lib/checkbox/checkbox-group.js.map +0 -1
- package/lib/radio/radio-group.d.ts +0 -8
- package/lib/radio/radio-group.d.ts.map +0 -1
- package/lib/radio/radio-group.js +0 -12
- package/lib/radio/radio-group.js.map +0 -1
- package/lib/steps/stepStyle/small.less +0 -5
- package/lib/upload/svg/UploadSVG.d.ts.map +0 -1
- package/lib/upload/svg/UploadSVG.js +0 -44
- package/lib/upload/svg/UploadSVG.js.map +0 -1
- package/lib/upload/upload.less +0 -108
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
.tnt-queryform {
|
|
2
|
+
display: flex;
|
|
3
|
+
|
|
4
|
+
&-extra {
|
|
5
|
+
line-height: 32px;
|
|
6
|
+
margin-left: 12px;
|
|
7
|
+
& > * {
|
|
8
|
+
margin-left: 8px;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&-actions {
|
|
13
|
+
align-items: center;
|
|
14
|
+
display: inline-block;
|
|
15
|
+
height: 32px;
|
|
16
|
+
line-height: 32px;
|
|
17
|
+
|
|
18
|
+
& > *:not(.expand-link) {
|
|
19
|
+
margin-right: 10px;
|
|
20
|
+
}
|
|
21
|
+
& > .expand-link {
|
|
22
|
+
padding: 0;
|
|
23
|
+
margin-right: 0;
|
|
24
|
+
}
|
|
25
|
+
& > .ant-badge {
|
|
26
|
+
.tnt-icon {
|
|
27
|
+
margin-right: 8px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ant-form {
|
|
33
|
+
display: inline-block;
|
|
34
|
+
margin-bottom: 12px;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex: 1;
|
|
37
|
+
&.ant-form-inline {
|
|
38
|
+
flex-wrap: unset;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
& > div:nth-child(1) {
|
|
42
|
+
height: 32px;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
.ant-form-item-label {
|
|
45
|
+
label {
|
|
46
|
+
// bottom: 4px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.expanded {
|
|
52
|
+
& > div:nth-child(1) {
|
|
53
|
+
height: auto !important;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&.showMore {
|
|
58
|
+
& > div:nth-child(1) {
|
|
59
|
+
.ant-form-item {
|
|
60
|
+
margin-bottom: 12px;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
& > div:nth-child(2) {
|
|
66
|
+
display: flex;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&.ant-form-inline .ant-form-item {
|
|
70
|
+
margin-right: 10px;
|
|
71
|
+
display: inline-block;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ant-form-item-control {
|
|
75
|
+
// min-width: 160px;
|
|
76
|
+
line-height: unset;
|
|
77
|
+
.ant-calendar-picker-input {
|
|
78
|
+
padding: 0 11px;
|
|
79
|
+
}
|
|
80
|
+
.ant-form-item-children {
|
|
81
|
+
& > .ant-input,
|
|
82
|
+
& > .ant-input-affix-wrapper {
|
|
83
|
+
width: 160px;
|
|
84
|
+
// width: 200px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&-drawer {
|
|
91
|
+
margin-top: 50px;
|
|
92
|
+
&.large-size {
|
|
93
|
+
margin-top: 60px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.ant-drawer.ant-drawer-open {
|
|
97
|
+
.ant-drawer-mask {
|
|
98
|
+
opacity: 0;
|
|
99
|
+
background: unset;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
.ant-drawer-body {
|
|
103
|
+
.ant-form-item {
|
|
104
|
+
display: block;
|
|
105
|
+
margin-right: 0;
|
|
106
|
+
margin-bottom: 20px;
|
|
107
|
+
width: 100%;
|
|
108
|
+
}
|
|
109
|
+
.ant-form-item-label {
|
|
110
|
+
display: block;
|
|
111
|
+
text-align: left;
|
|
112
|
+
line-height: 22px;
|
|
113
|
+
margin-bottom: 10px;
|
|
114
|
+
}
|
|
115
|
+
.ant-form-item-control-wrapper,
|
|
116
|
+
.ant-form-item-control,
|
|
117
|
+
.ant-calendar-picker,
|
|
118
|
+
.ant-input {
|
|
119
|
+
min-width: 100%;
|
|
120
|
+
width: 100%;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
& > .ant-btn {
|
|
124
|
+
display: block;
|
|
125
|
+
width: 100%;
|
|
126
|
+
margin-bottom: 10px;
|
|
127
|
+
&.ant-btn-primary {
|
|
128
|
+
margin-top: 20px;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { forwardRef, useContext, useImperativeHandle, useState } from 'react';
|
|
2
|
+
import Context from './Context';
|
|
3
|
+
import Thumb from './Thumb';
|
|
4
|
+
import { GAP } from './util';
|
|
5
|
+
export default forwardRef((props, ref) => {
|
|
6
|
+
const {
|
|
7
|
+
wrapElement
|
|
8
|
+
} = useContext(Context);
|
|
9
|
+
const [moveX, setMoveX] = useState(0);
|
|
10
|
+
const [moveY, setMoveY] = useState(0);
|
|
11
|
+
const [sizeWidth, setSizeWidth] = useState(0);
|
|
12
|
+
const [sizeHeight, setSizeHeight] = useState(0);
|
|
13
|
+
const [ratioX, setRatioX] = useState(1);
|
|
14
|
+
const [ratioY, setRatioY] = useState(1);
|
|
15
|
+
useImperativeHandle(ref, () => ({
|
|
16
|
+
update,
|
|
17
|
+
handleScroll
|
|
18
|
+
}));
|
|
19
|
+
function handleScroll() {
|
|
20
|
+
const wrap = wrapElement.current;
|
|
21
|
+
if (!wrap) return;
|
|
22
|
+
const offsetHeight = wrap.offsetHeight - GAP;
|
|
23
|
+
const offsetWidth = wrap.offsetWidth - GAP;
|
|
24
|
+
setMoveY(wrap.scrollTop * 100 / offsetHeight * ratioY);
|
|
25
|
+
setMoveX(wrap.scrollLeft * 100 / offsetWidth * ratioX);
|
|
26
|
+
}
|
|
27
|
+
function update() {
|
|
28
|
+
const wrap = wrapElement.current;
|
|
29
|
+
if (!wrap) return;
|
|
30
|
+
// 滚动窗口的高度
|
|
31
|
+
const offsetHeight = wrap.offsetHeight - GAP;
|
|
32
|
+
const offsetWidth = wrap.offsetWidth - GAP;
|
|
33
|
+
// 滚动条的逻辑高度
|
|
34
|
+
const originalHeight = offsetHeight ** 2 / wrap.scrollHeight;
|
|
35
|
+
const originalWidth = offsetWidth ** 2 / wrap.scrollWidth;
|
|
36
|
+
// 滚动条的实际高度,因为如果内容太长会导致滚动条非常短,可能难以点击拖拽,所以设置了最小高度
|
|
37
|
+
const height = Math.max(originalHeight, props.minSize);
|
|
38
|
+
const width = Math.max(originalWidth, props.minSize);
|
|
39
|
+
setRatioY(originalHeight / (offsetHeight - originalHeight) / (height / (offsetHeight - height)));
|
|
40
|
+
setRatioX(originalWidth / (offsetWidth - originalWidth) / (width / (offsetWidth - width)));
|
|
41
|
+
setSizeHeight(height + GAP < offsetHeight ? height : 0);
|
|
42
|
+
setSizeWidth(width + GAP < offsetWidth ? width : 0);
|
|
43
|
+
}
|
|
44
|
+
return React.createElement(React.Fragment, null, React.createElement(Thumb, {
|
|
45
|
+
always: props.always,
|
|
46
|
+
move: moveX,
|
|
47
|
+
size: sizeWidth,
|
|
48
|
+
ratio: ratioX
|
|
49
|
+
}), React.createElement(Thumb, {
|
|
50
|
+
always: props.always,
|
|
51
|
+
move: moveY,
|
|
52
|
+
size: sizeHeight,
|
|
53
|
+
ratio: ratioY,
|
|
54
|
+
vertical: true
|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AC,CAAC,CAAC,CAAC,CAAA;QACvD,YAAY,CAAC,KAAK,GAAG,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACrD,CAAC;IAED,OAAO,CACL;QACE,oBAAC,KAAK,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAI;QAC5E,oBAAC,KAAK,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAG,CACrF,CACJ,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import React, { forwardRef, useContext, useImperativeHandle, useState } from 'react'\nimport Context from './Context'\nimport Thumb from './Thumb'\nimport { GAP } from './util'\n\nexport default forwardRef((props, ref) => {\n const { wrapElement } = useContext(Context)\n\n const [moveX, setMoveX] = useState(0)\n const [moveY, setMoveY] = useState(0)\n const [sizeWidth, setSizeWidth] = useState(0)\n const [sizeHeight, setSizeHeight] = useState(0)\n const [ratioX, setRatioX] = useState(1)\n const [ratioY, setRatioY] = useState(1)\n\n useImperativeHandle(ref, () => ({\n update,\n handleScroll,\n }))\n\n function handleScroll() {\n const wrap = wrapElement.current\n if (!wrap) return\n const offsetHeight = wrap.offsetHeight - GAP\n const offsetWidth = wrap.offsetWidth - GAP\n setMoveY(((wrap.scrollTop * 100) / offsetHeight) * ratioY)\n setMoveX(((wrap.scrollLeft * 100) / offsetWidth) * ratioX)\n }\n\n function update() {\n const wrap = wrapElement.current\n if (!wrap) return\n // 滚动窗口的高度\n const offsetHeight = wrap.offsetHeight - GAP\n const offsetWidth = wrap.offsetWidth - GAP\n // 滚动条的逻辑高度\n const originalHeight = offsetHeight ** 2 / wrap.scrollHeight\n const originalWidth = offsetWidth ** 2 / wrap.scrollWidth\n // 滚动条的实际高度,因为如果内容太长会导致滚动条非常短,可能难以点击拖拽,所以设置了最小高度\n const height = Math.max(originalHeight, props.minSize)\n const width = Math.max(originalWidth, props.minSize)\n\n setRatioY(originalHeight / (offsetHeight - originalHeight) / (height / (offsetHeight - height)))\n setRatioX(originalWidth / (offsetWidth - originalWidth) / (width / (offsetWidth - width)))\n setSizeHeight(height + GAP < offsetHeight ? height : 0)\n setSizeWidth(width + GAP < offsetWidth ? width : 0)\n }\n\n return (\n <>\n <Thumb always={props.always} move={moveX} size={sizeWidth} ratio={ratioX} />\n <Thumb always={props.always} move={moveY} size={sizeHeight} ratio={ratioY} vertical />\n </>\n )\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/scroll-bar/Context.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC;IAClC,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,IAAI;CAClB,CAAC,CAAA;AAEF,eAAe,OAAO,CAAA","sourcesContent":["import React from 'react'\n\nconst Context = React.createContext({\n scrollbarElement: null,\n wrapElement: null,\n})\n\nexport default Context\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
4
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
5
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
6
|
+
}
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
import clsx from 'classnames';
|
|
10
|
+
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
11
|
+
import Bar from './Bar';
|
|
12
|
+
import Context from './Context';
|
|
13
|
+
export default forwardRef((_a, ref) => {
|
|
14
|
+
var {
|
|
15
|
+
children,
|
|
16
|
+
minSize = 20
|
|
17
|
+
} = _a,
|
|
18
|
+
props = __rest(_a, ["children", "minSize"]);
|
|
19
|
+
const scrollbarElement = useRef();
|
|
20
|
+
let wrapElement = useRef();
|
|
21
|
+
wrapElement = ref || wrapElement;
|
|
22
|
+
const resizeRef = useRef();
|
|
23
|
+
const barRef = useRef();
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const wrapDom = wrapElement.current;
|
|
26
|
+
const resizeDom = resizeRef.current;
|
|
27
|
+
// 监听容器尺寸变化,因为尺寸可以设置类似height:100vh之类样式,高度并不是固定的
|
|
28
|
+
const observerCallback = () => requestAnimationFrame(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
update();
|
|
31
|
+
(_a = barRef.current) === null || _a === void 0 ? void 0 : _a.handleScroll();
|
|
32
|
+
});
|
|
33
|
+
const observer = new ResizeObserver(observerCallback);
|
|
34
|
+
observer.observe(wrapDom);
|
|
35
|
+
observer.observe(resizeDom);
|
|
36
|
+
return () => {
|
|
37
|
+
observer.unobserve(wrapDom);
|
|
38
|
+
observer.unobserve(resizeDom);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
var _a;
|
|
43
|
+
if (!props.native) {
|
|
44
|
+
update();
|
|
45
|
+
(_a = barRef.current) === null || _a === void 0 ? void 0 : _a.handleScroll();
|
|
46
|
+
}
|
|
47
|
+
}, [props.native]);
|
|
48
|
+
function update() {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = barRef.current) === null || _a === void 0 ? void 0 : _a.update();
|
|
51
|
+
}
|
|
52
|
+
function handleScroll(e) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
(_a = barRef.current) === null || _a === void 0 ? void 0 : _a.handleScroll();
|
|
55
|
+
(_b = props.onScroll) === null || _b === void 0 ? void 0 : _b.call(props, e);
|
|
56
|
+
}
|
|
57
|
+
const wrapStyle = {
|
|
58
|
+
height: props.height,
|
|
59
|
+
maxHeight: props.maxHeight
|
|
60
|
+
};
|
|
61
|
+
const wrapClassName = clsx('tntd-scroll-bar-wrap', {
|
|
62
|
+
'tntd-scroll-bar-wrap-hidden-default': !props.native
|
|
63
|
+
});
|
|
64
|
+
return React.createElement(Context.Provider, {
|
|
65
|
+
value: {
|
|
66
|
+
scrollbarElement,
|
|
67
|
+
wrapElement
|
|
68
|
+
}
|
|
69
|
+
}, React.createElement("div", {
|
|
70
|
+
style: props.style,
|
|
71
|
+
className: clsx('tntd-scroll-bar', props.className),
|
|
72
|
+
ref: scrollbarElement
|
|
73
|
+
}, React.createElement("div", {
|
|
74
|
+
style: wrapStyle,
|
|
75
|
+
className: wrapClassName,
|
|
76
|
+
ref: wrapElement,
|
|
77
|
+
onScroll: handleScroll
|
|
78
|
+
}, React.createElement("div", {
|
|
79
|
+
className: "tntd-scroll-bar-view",
|
|
80
|
+
ref: resizeRef
|
|
81
|
+
}, children)), !props.native && React.createElement(Bar, {
|
|
82
|
+
ref: barRef,
|
|
83
|
+
always: props.always,
|
|
84
|
+
minSize: minSize
|
|
85
|
+
})));
|
|
86
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollBar.js","sourceRoot":"","sources":["../../src/scroll-bar/ScrollBar.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,YAAY,CAAA;AAC7B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,GAAG,MAAM,OAAO,CAAA;AACvB,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,eAAe,UAAU,CAAC,CAAC,EAAoC,EAAE,GAAG,EAAE,EAAE;QAA7C,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE,OAAY,EAAP,K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;QACrB,MAAA,MAAM,CAAC,OAAO,0CAAE,YAAY,EAAE,CAAA;QAC9B,MAAA,KAAK,CAAC,QAAQ,sDAAG,CAAC,CAAC,CAAA;IACrB,CAAC;IAED,MAAM,SAAS,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;IACtE,MAAM,aAAa,GAAG,IAAI,CAAC,sBAAsB,EAAE;QACjD,qCAAqC,EAAE,CAAC,KAAK,CAAC,MAAM;KACrD,CAAC,CAAA;IAEF,OAAO,CACL,oBAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,gBAAgB,EAAE,WAAW,EAAE;QACxD,6BACE,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,EACnD,GAAG,EAAE,gBAAgB;YAErB,6BAAK,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY;gBACvF,6BAAK,SAAS,EAAC,sBAAsB,EAAC,GAAG,EAAE,SAAS,IACjD,QAAQ,CACL,CACF;YACL,CAAC,KAAK,CAAC,MAAM,IAAI,oBAAC,GAAG,IAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAI,CAC1E,CACW,CACpB,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import clsx from 'classnames'\nimport React, { forwardRef, useEffect, useRef } from 'react'\nimport Bar from './Bar'\nimport Context from './Context'\n\nexport default forwardRef(({ children, minSize = 20, ...props }, ref) => {\n const scrollbarElement = useRef()\n let wrapElement = useRef()\n wrapElement = ref || wrapElement\n const resizeRef = useRef()\n const barRef = useRef()\n\n useEffect(() => {\n const wrapDom = wrapElement.current\n const resizeDom = resizeRef.current\n // 监听容器尺寸变化,因为尺寸可以设置类似height:100vh之类样式,高度并不是固定的\n const observerCallback = () =>\n requestAnimationFrame(() => {\n update()\n barRef.current?.handleScroll()\n })\n const observer = new ResizeObserver(observerCallback)\n observer.observe(wrapDom)\n observer.observe(resizeDom)\n return () => {\n observer.unobserve(wrapDom)\n observer.unobserve(resizeDom)\n }\n }, [])\n useEffect(() => {\n if (!props.native) {\n update()\n barRef.current?.handleScroll()\n }\n }, [props.native])\n\n function update() {\n barRef.current?.update()\n }\n\n function handleScroll(e) {\n barRef.current?.handleScroll()\n props.onScroll?.(e)\n }\n\n const wrapStyle = { height: props.height, maxHeight: props.maxHeight }\n const wrapClassName = clsx('tntd-scroll-bar-wrap', {\n 'tntd-scroll-bar-wrap-hidden-default': !props.native,\n })\n\n return (\n <Context.Provider value={{ scrollbarElement, wrapElement }}>\n <div\n style={props.style}\n className={clsx('tntd-scroll-bar', props.className)}\n ref={scrollbarElement}\n >\n <div style={wrapStyle} className={wrapClassName} ref={wrapElement} onScroll={handleScroll}>\n <div className=\"tntd-scroll-bar-view\" ref={resizeRef}>\n {children}\n </div>\n </div>\n {!props.native && <Bar ref={barRef} always={props.always} minSize={minSize} />}\n </div>\n </Context.Provider>\n )\n})\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import clsx from 'classnames';
|
|
2
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Context from './Context';
|
|
4
|
+
import { BAR_MAP, renderThumbStyle } from './util';
|
|
5
|
+
export default function Thumb(props) {
|
|
6
|
+
const {
|
|
7
|
+
scrollbarElement,
|
|
8
|
+
wrapElement
|
|
9
|
+
} = useContext(Context);
|
|
10
|
+
const instance = useRef();
|
|
11
|
+
const thumb = useRef();
|
|
12
|
+
const [visible, setVisible] = useState(false);
|
|
13
|
+
// 当作非响应式变量使用
|
|
14
|
+
const thumbState = useRef({});
|
|
15
|
+
const cursorDown = useRef(false);
|
|
16
|
+
const cursorLeave = useRef(false);
|
|
17
|
+
const originalOnSelectStart = useRef(document.onselectstart);
|
|
18
|
+
const bar = BAR_MAP[props.vertical ? 'vertical' : 'horizontal'];
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const element = scrollbarElement.current;
|
|
21
|
+
element.addEventListener('mousemove', mouseMoveScrollbarHandler);
|
|
22
|
+
element.addEventListener('mouseleave', mouseLeaveScrollbarHandler);
|
|
23
|
+
return () => {
|
|
24
|
+
restoreOnselectstart();
|
|
25
|
+
document.removeEventListener('mouseup', mouseUpDocumentHandler);
|
|
26
|
+
element.removeEventListener('mousemove', mouseMoveScrollbarHandler);
|
|
27
|
+
element.removeEventListener('mouseleave', mouseLeaveScrollbarHandler);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
function mouseMoveScrollbarHandler() {
|
|
31
|
+
cursorLeave.current = false;
|
|
32
|
+
setVisible(true);
|
|
33
|
+
}
|
|
34
|
+
function mouseLeaveScrollbarHandler() {
|
|
35
|
+
cursorLeave.current = true;
|
|
36
|
+
setVisible(cursorDown.current);
|
|
37
|
+
}
|
|
38
|
+
function getOffsetRatio() {
|
|
39
|
+
return instance.current[bar.offset] ** 2 / wrapElement.current[bar.scrollSize] / props.ratio / thumb.current[bar.offset];
|
|
40
|
+
}
|
|
41
|
+
function clickTrackHandler(e) {
|
|
42
|
+
if (!thumb.current || !instance.current || !wrapElement.current) return;
|
|
43
|
+
// 鼠标点击的坐标距离顶端的距离
|
|
44
|
+
const offset = Math.abs(e.target.getBoundingClientRect()[bar.direction] - e[bar.client]);
|
|
45
|
+
const thumbHalf = thumb.current[bar.offset] / 2;
|
|
46
|
+
const thumbPositionPercentage = (offset - thumbHalf) * 100 * getOffsetRatio() / instance.current[bar.offset];
|
|
47
|
+
// 直接给scrollTop赋值,就会调用bar组件的handleScroll函数
|
|
48
|
+
wrapElement.current[bar.scroll] = thumbPositionPercentage * wrapElement.current[bar.scrollSize] / 100;
|
|
49
|
+
}
|
|
50
|
+
function clickThumbHandler(e) {
|
|
51
|
+
var _a;
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
if (e.ctrlKey || [1, 2].includes(e.button)) return;
|
|
54
|
+
(_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
55
|
+
startDrag(e);
|
|
56
|
+
const el = e.currentTarget;
|
|
57
|
+
if (!el) return;
|
|
58
|
+
thumbState.current[bar.axis] = el[bar.offset] - (e[bar.client] - el.getBoundingClientRect()[bar.direction]);
|
|
59
|
+
}
|
|
60
|
+
function startDrag(e) {
|
|
61
|
+
e.persist();
|
|
62
|
+
cursorDown.current = true;
|
|
63
|
+
document.addEventListener('mousemove', mouseMoveDocumentHandler);
|
|
64
|
+
document.addEventListener('mouseup', mouseUpDocumentHandler);
|
|
65
|
+
originalOnSelectStart.current = document.onselectstart;
|
|
66
|
+
document.onselectstart = () => false;
|
|
67
|
+
}
|
|
68
|
+
function mouseMoveDocumentHandler(e) {
|
|
69
|
+
if (!instance.current || !thumb.current) return;
|
|
70
|
+
if (cursorDown.current === false) return;
|
|
71
|
+
const prevPage = thumbState.current[bar.axis];
|
|
72
|
+
if (!prevPage) return;
|
|
73
|
+
const offset = (instance.current.getBoundingClientRect()[bar.direction] - e[bar.client]) * -1;
|
|
74
|
+
const thumbClickPosition = thumb.current[bar.offset] - prevPage;
|
|
75
|
+
const thumbPositionPercentage = (offset - thumbClickPosition) * 100 * getOffsetRatio() / instance.current[bar.offset];
|
|
76
|
+
wrapElement.current[bar.scroll] = thumbPositionPercentage * wrapElement.current[bar.scrollSize] / 100;
|
|
77
|
+
}
|
|
78
|
+
function mouseUpDocumentHandler() {
|
|
79
|
+
cursorDown.current = false;
|
|
80
|
+
thumbState.current[bar.axis] = 0;
|
|
81
|
+
document.removeEventListener('mousemove', mouseMoveDocumentHandler);
|
|
82
|
+
document.removeEventListener('mouseup', mouseUpDocumentHandler);
|
|
83
|
+
restoreOnselectstart();
|
|
84
|
+
if (cursorLeave.current) setVisible(false);
|
|
85
|
+
}
|
|
86
|
+
function restoreOnselectstart() {
|
|
87
|
+
if (document.onselectstart !== originalOnSelectStart.current) document.onselectstart = originalOnSelectStart.current;
|
|
88
|
+
}
|
|
89
|
+
const thumbStyle = renderThumbStyle({
|
|
90
|
+
size: props.size,
|
|
91
|
+
move: props.move,
|
|
92
|
+
bar: bar
|
|
93
|
+
});
|
|
94
|
+
return React.createElement("div", {
|
|
95
|
+
hidden: !(props.always || visible),
|
|
96
|
+
className: clsx('tntd-scroll-bar-bar', bar.key),
|
|
97
|
+
ref: instance,
|
|
98
|
+
onMouseDown: clickTrackHandler
|
|
99
|
+
}, React.createElement("div", {
|
|
100
|
+
className: "tntd-scroll-bar-thumb",
|
|
101
|
+
style: thumbStyle,
|
|
102
|
+
ref: thumb,
|
|
103
|
+
onMouseDown: clickThumbHandler
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Thumb.js","sourceRoot":"","sources":["../../src/scroll-bar/Thumb.js"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,YAAY,CAAA;AAC7B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAElD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,KAAK;IACjC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IAC7D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAA;IACzB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAA;IACtB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC7C,aAAa;IACb,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;IAC7B,MAAM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["import clsx from 'classnames'\nimport React, { useContext, useEffect, useRef, useState } from 'react'\nimport Context from './Context'\nimport { BAR_MAP, renderThumbStyle } from './util'\n\nexport default function Thumb(props) {\n const { scrollbarElement, wrapElement } = useContext(Context)\n const instance = useRef()\n const thumb = useRef()\n const [visible, setVisible] = useState(false)\n // 当作非响应式变量使用\n const thumbState = useRef({})\n const cursorDown = useRef(false)\n const cursorLeave = useRef(false)\n const originalOnSelectStart = useRef(document.onselectstart)\n const bar = BAR_MAP[props.vertical ? 'vertical' : 'horizontal']\n\n useEffect(() => {\n const element = scrollbarElement.current\n element.addEventListener('mousemove', mouseMoveScrollbarHandler)\n element.addEventListener('mouseleave', mouseLeaveScrollbarHandler)\n return () => {\n restoreOnselectstart()\n document.removeEventListener('mouseup', mouseUpDocumentHandler)\n element.removeEventListener('mousemove', mouseMoveScrollbarHandler)\n element.removeEventListener('mouseleave', mouseLeaveScrollbarHandler)\n }\n }, [])\n\n function mouseMoveScrollbarHandler() {\n cursorLeave.current = false\n setVisible(true)\n }\n\n function mouseLeaveScrollbarHandler() {\n cursorLeave.current = true\n setVisible(cursorDown.current)\n }\n\n function getOffsetRatio() {\n return (\n instance.current[bar.offset] ** 2 /\n wrapElement.current[bar.scrollSize] /\n props.ratio /\n thumb.current[bar.offset]\n )\n }\n\n function clickTrackHandler(e) {\n if (!thumb.current || !instance.current || !wrapElement.current) return\n // 鼠标点击的坐标距离顶端的距离\n const offset = Math.abs(e.target.getBoundingClientRect()[bar.direction] - e[bar.client])\n const thumbHalf = thumb.current[bar.offset] / 2\n const thumbPositionPercentage =\n ((offset - thumbHalf) * 100 * getOffsetRatio()) / instance.current[bar.offset]\n // 直接给scrollTop赋值,就会调用bar组件的handleScroll函数\n wrapElement.current[bar.scroll] =\n (thumbPositionPercentage * wrapElement.current[bar.scrollSize]) / 100\n }\n\n function clickThumbHandler(e) {\n e.stopPropagation()\n if (e.ctrlKey || [1, 2].includes(e.button)) return\n window.getSelection()?.removeAllRanges()\n startDrag(e)\n\n const el = e.currentTarget\n if (!el) return\n thumbState.current[bar.axis] =\n el[bar.offset] - (e[bar.client] - el.getBoundingClientRect()[bar.direction])\n }\n\n function startDrag(e) {\n e.persist()\n cursorDown.current = true\n document.addEventListener('mousemove', mouseMoveDocumentHandler)\n document.addEventListener('mouseup', mouseUpDocumentHandler)\n originalOnSelectStart.current = document.onselectstart\n document.onselectstart = () => false\n }\n\n function mouseMoveDocumentHandler(e) {\n if (!instance.current || !thumb.current) return\n if (cursorDown.current === false) return\n const prevPage = thumbState.current[bar.axis]\n if (!prevPage) return\n\n const offset = (instance.current.getBoundingClientRect()[bar.direction] - e[bar.client]) * -1\n const thumbClickPosition = thumb.current[bar.offset] - prevPage\n const thumbPositionPercentage =\n ((offset - thumbClickPosition) * 100 * getOffsetRatio()) / instance.current[bar.offset]\n wrapElement.current[bar.scroll] =\n (thumbPositionPercentage * wrapElement.current[bar.scrollSize]) / 100\n }\n\n function mouseUpDocumentHandler() {\n cursorDown.current = false\n thumbState.current[bar.axis] = 0\n document.removeEventListener('mousemove', mouseMoveDocumentHandler)\n document.removeEventListener('mouseup', mouseUpDocumentHandler)\n restoreOnselectstart()\n if (cursorLeave.current) setVisible(false)\n }\n\n function restoreOnselectstart() {\n if (document.onselectstart !== originalOnSelectStart.current)\n document.onselectstart = originalOnSelectStart.current\n }\n\n const thumbStyle = renderThumbStyle({\n size: props.size,\n move: props.move,\n bar: bar,\n })\n\n return (\n <div\n hidden={!(props.always || visible)}\n className={clsx('tntd-scroll-bar-bar', bar.key)}\n ref={instance}\n onMouseDown={clickTrackHandler}\n >\n <div\n className=\"tntd-scroll-bar-thumb\"\n style={thumbStyle}\n ref={thumb}\n onMouseDown={clickThumbHandler}\n />\n </div>\n )\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scroll-bar/index.js"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,kBAAkB,CAAA;AAEzB,eAAe,SAAS,CAAA","sourcesContent":["import ScrollBar from './ScrollBar'\nimport './scrollBar.less'\n\nexport default ScrollBar\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.tntd-scroll-bar {
|
|
2
|
+
position: relative;
|
|
3
|
+
height: 100%;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
.tntd-scroll-bar-wrap {
|
|
7
|
+
height: 100%;
|
|
8
|
+
overflow: auto;
|
|
9
|
+
}
|
|
10
|
+
.tntd-scroll-bar-wrap-hidden-default {
|
|
11
|
+
scrollbar-width: none;
|
|
12
|
+
&::-webkit-scrollbar {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
.tntd-scroll-bar-view {
|
|
17
|
+
width: fit-content;
|
|
18
|
+
min-width: 100%;
|
|
19
|
+
}
|
|
20
|
+
.tntd-scroll-bar-bar {
|
|
21
|
+
position: absolute;
|
|
22
|
+
right: 2px;
|
|
23
|
+
bottom: 2px;
|
|
24
|
+
z-index: 1;
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
|
|
27
|
+
&.vertical {
|
|
28
|
+
top: 2px;
|
|
29
|
+
width: 6px;
|
|
30
|
+
|
|
31
|
+
> div {
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.horizontal {
|
|
37
|
+
left: 2px;
|
|
38
|
+
height: 6px;
|
|
39
|
+
|
|
40
|
+
> div {
|
|
41
|
+
height: 100%;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
.tntd-scroll-bar-thumb {
|
|
46
|
+
position: relative;
|
|
47
|
+
display: block;
|
|
48
|
+
width: 0;
|
|
49
|
+
height: 0;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
background-color: #909399;
|
|
52
|
+
border-radius: inherit;
|
|
53
|
+
opacity: 0.3;
|
|
54
|
+
transition: 0.3s background-color;
|
|
55
|
+
|
|
56
|
+
&:hover {
|
|
57
|
+
opacity: 0.5;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const GAP = 4; // top 2 + bottom 2 of bar instance
|
|
2
|
+
export const BAR_MAP = {
|
|
3
|
+
vertical: {
|
|
4
|
+
offset: 'offsetHeight',
|
|
5
|
+
scroll: 'scrollTop',
|
|
6
|
+
scrollSize: 'scrollHeight',
|
|
7
|
+
size: 'height',
|
|
8
|
+
key: 'vertical',
|
|
9
|
+
axis: 'Y',
|
|
10
|
+
client: 'clientY',
|
|
11
|
+
direction: 'top'
|
|
12
|
+
},
|
|
13
|
+
horizontal: {
|
|
14
|
+
offset: 'offsetWidth',
|
|
15
|
+
scroll: 'scrollLeft',
|
|
16
|
+
scrollSize: 'scrollWidth',
|
|
17
|
+
size: 'width',
|
|
18
|
+
key: 'horizontal',
|
|
19
|
+
axis: 'X',
|
|
20
|
+
client: 'clientX',
|
|
21
|
+
direction: 'left'
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const renderThumbStyle = ({
|
|
25
|
+
move,
|
|
26
|
+
size,
|
|
27
|
+
bar
|
|
28
|
+
}) => ({
|
|
29
|
+
[bar.size]: size,
|
|
30
|
+
transform: `translate${bar.axis}(${move}%)`
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/scroll-bar/util.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA,CAAC,mCAAmC;AAExD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE;QACR,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,WAAW;QACnB,UAAU,EAAE,cAAc;QAC1B,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,UAAU;QACf,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,KAAK;KACjB;IACD,UAAU,EAAE;QACV,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,YAAY;QACpB,UAAU,EAAE,aAAa;QACzB,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,MAAM;KAClB;CACF,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI;IAChB,SAAS,EAAE,YAAY,GAAG,CAAC,IAAI,IAAI,IAAI,IAAI;CAC5C,CAAC,CAAA","sourcesContent":["export const GAP = 4 // top 2 + bottom 2 of bar instance\n\nexport const BAR_MAP = {\n vertical: {\n offset: 'offsetHeight',\n scroll: 'scrollTop',\n scrollSize: 'scrollHeight',\n size: 'height',\n key: 'vertical',\n axis: 'Y',\n client: 'clientY',\n direction: 'top',\n },\n horizontal: {\n offset: 'offsetWidth',\n scroll: 'scrollLeft',\n scrollSize: 'scrollWidth',\n size: 'width',\n key: 'horizontal',\n axis: 'X',\n client: 'clientX',\n direction: 'left',\n },\n}\n\nexport const renderThumbStyle = ({ move, size, bar }) => ({\n [bar.size]: size,\n transform: `translate${bar.axis}(${move}%)`,\n})\n"]}
|
package/es/table/table.js
CHANGED
|
@@ -20,7 +20,6 @@ import { TableContext } from './context';
|
|
|
20
20
|
import { useColumnSetting, useExpandFixed } from './hooks';
|
|
21
21
|
import { normalizeColumns } from './utils';
|
|
22
22
|
import { titleCaseUpper } from '../utils/lang';
|
|
23
|
-
import { TotalShower } from './total-shower';
|
|
24
23
|
import { getLanguage } from '../prev-locale';
|
|
25
24
|
import ResizeObserver from 'rc-resize-observer';
|
|
26
25
|
const sizeWidthMap = {
|
|
@@ -29,12 +28,6 @@ const sizeWidthMap = {
|
|
|
29
28
|
small: 20,
|
|
30
29
|
xs: 16 // 8
|
|
31
30
|
};
|
|
32
|
-
const getDefaultPagination = locale => ({
|
|
33
|
-
showTotal: total => React.createElement(TotalShower, {
|
|
34
|
-
total: total,
|
|
35
|
-
locale: locale
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
31
|
// 判断是否是特殊的tooltip
|
|
39
32
|
// const checkIsPrompt = (dom: any): boolean => {
|
|
40
33
|
// let isPrompt: boolean = false
|
|
@@ -60,7 +53,7 @@ export const Table = _a => {
|
|
|
60
53
|
shadowed,
|
|
61
54
|
striped = true,
|
|
62
55
|
showCellBorders = false,
|
|
63
|
-
|
|
56
|
+
pagination,
|
|
64
57
|
enableToolbar = false,
|
|
65
58
|
refresh,
|
|
66
59
|
upperCaseIgnore,
|
|
@@ -70,7 +63,7 @@ export const Table = _a => {
|
|
|
70
63
|
smallPadding,
|
|
71
64
|
rowClassName
|
|
72
65
|
} = _a,
|
|
73
|
-
rest = __rest(_a, ["className", "locale", "bordered", "size", "storageKey", "columns", "children", "sticky", "shadowed", "striped", "showCellBorders", "enableToolbar", "refresh", "upperCaseIgnore", "unUpperConverted", "unTooltip", "smallPadding", "rowClassName"]);
|
|
66
|
+
rest = __rest(_a, ["className", "locale", "bordered", "size", "storageKey", "columns", "children", "sticky", "shadowed", "striped", "showCellBorders", "pagination", "enableToolbar", "refresh", "upperCaseIgnore", "unUpperConverted", "unTooltip", "smallPadding", "rowClassName"]);
|
|
74
67
|
const tableContainer = useRef(null);
|
|
75
68
|
// const [innerSize, setInnerSize] = useLocalStorage<TableProps<T>['size']>(
|
|
76
69
|
// TABLE_SIZE_STORAGE_KEY,
|
|
@@ -228,7 +221,9 @@ export const Table = _a => {
|
|
|
228
221
|
defaultLocale: locale
|
|
229
222
|
}, localeObject => {
|
|
230
223
|
// const locale = localeObject as Record<string, string>
|
|
231
|
-
|
|
224
|
+
const paginationConfig = pagination !== false ? Object.assign(Object.assign({}, pagination || {}), {
|
|
225
|
+
hideOnSinglePage: (pagination === null || pagination === void 0 ? void 0 : pagination.hideOnSinglePage) === false ? false : true
|
|
226
|
+
}) : pagination;
|
|
232
227
|
return React.createElement(ResizeObserver, {
|
|
233
228
|
onResize: ({
|
|
234
229
|
width
|
|
@@ -254,7 +249,8 @@ export const Table = _a => {
|
|
|
254
249
|
bordered: bordered,
|
|
255
250
|
size: size,
|
|
256
251
|
columns: newColumns,
|
|
257
|
-
rowClassName: getRowClassName(prefixCls)
|
|
252
|
+
rowClassName: getRowClassName(prefixCls),
|
|
253
|
+
pagination: paginationConfig
|
|
258
254
|
}, rest, sticky ? stickyProps : {})));
|
|
259
255
|
}));
|
|
260
256
|
}));
|