react-ui-basics 0.0.220 → 0.0.222
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/Animated.js +1 -0
- package/Animated.js.map +1 -1
- package/Button.js.map +1 -1
- package/Dialog.d.ts +29 -0
- package/Dialog.js +84 -143
- package/Dialog.js.map +1 -1
- package/FilteredList.css +1 -1
- package/FilteredList.d.ts +62 -0
- package/FilteredList.js +128 -232
- package/FilteredList.js.map +1 -1
- package/FormUploadProgress.d.ts +19 -0
- package/FormUploadProgress.js +14 -39
- package/FormUploadProgress.js.map +1 -1
- package/Modal.d.ts +31 -0
- package/Modal.js +102 -134
- package/Modal.js.map +1 -1
- package/ReactConstants.d.ts +6 -2
- package/ReactConstants.js.map +1 -1
- package/ReactCreateElement.d.ts +3 -0
- package/ReactCreateElement.js.map +1 -1
- package/ReadyListener.d.ts +34 -0
- package/ReadyListener.js +34 -56
- package/ReadyListener.js.map +1 -1
- package/Scrollable.css +0 -1
- package/Scrollable.d.ts +33 -0
- package/Scrollable.js +310 -325
- package/Scrollable.js.map +1 -1
- package/_virtual/_rollupPluginBabelHelpers.js +0 -15
- package/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/bundle.css +829 -830
- package/package.json +1 -1
- package/router/Route.js +1 -0
- package/router/Route.js.map +1 -1
- package/src/Button.tsx +0 -1
- package/src/{Dialog.js → Dialog.tsx} +63 -44
- package/src/FilteredList.css +1 -1
- package/src/FilteredList.scss +1 -1
- package/src/{FilteredList.js → FilteredList.tsx} +95 -45
- package/src/{FormUploadProgress.js → FormUploadProgress.tsx} +13 -22
- package/src/{Modal.js → Modal.tsx} +48 -33
- package/src/ReactConstants.ts +9 -3
- package/src/ReactCreateElement.tsx +3 -0
- package/src/ReadyListener.tsx +58 -0
- package/src/Scrollable.css +0 -1
- package/src/Scrollable.scss +0 -1
- package/src/{Scrollable.js → Scrollable.tsx} +78 -64
- package/src/ReactCreateElement.js +0 -3
- package/src/ReadyListener.js +0 -48
package/Scrollable.js
CHANGED
|
@@ -1,333 +1,318 @@
|
|
|
1
|
-
import ReactConstants from "./ReactConstants"; import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./CommonFields"; import {toConsumableArray as __toConsumableArray} from "./_virtual/_rollupPluginBabelHelpers"; import {extends as __extends} from "./_virtual/_rollupPluginBabelHelpers"; import {inherits as __inherits} from "./_virtual/_rollupPluginBabelHelpers"; import './Scrollable.css'; import {
|
|
2
|
-
import 'react';
|
|
3
|
-
import ReactCreateElement from './ReactCreateElement.js';
|
|
4
|
-
import 'prop-types';
|
|
1
|
+
import ReactConstants from "./ReactConstants"; import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./CommonFields"; import {toConsumableArray as __toConsumableArray} from "./_virtual/_rollupPluginBabelHelpers"; import {extends as __extends} from "./_virtual/_rollupPluginBabelHelpers"; import {inherits as __inherits} from "./_virtual/_rollupPluginBabelHelpers"; import './Scrollable.css'; import { jsxs as jsxRuntime_1, jsx as jsxRuntime_2 } from 'react/jsx-runtime';
|
|
5
2
|
import { classNames, ref, createRef, clearInterval, clearTimeout, orNoop, addEventListener, WINDOW, preventDefault, setTimeout, setInterval, removeEventListener } from './Tools.js';
|
|
6
3
|
import { stateGS, componentDidMount, componentWillUnmount, componentDidUpdate, render, PureComponent, propsGetter } from './ReactConstants.js';
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
5
|
+
const SCROLLBAR_MODE_HIDDEN = 'hidden';
|
|
6
|
+
const SCROLLBAR_MODE_AUTO = 'auto';
|
|
7
|
+
const SCROLLBAR_RESIZE_DISABLED = 'disabled';
|
|
8
|
+
let NATIVE_SCROLL_WIDTH = -1;
|
|
9
|
+
let NATIVE_SCROLL_HEIGHT = -1;
|
|
10
|
+
const WITHOUT_SCROLL = 'without-scroll';
|
|
11
|
+
const WITH_SCROLL = 'with-scroll';
|
|
12
|
+
const createFieldGetter = field => el => el[field];
|
|
13
|
+
const scrollHeightOf = createFieldGetter('scrollHeight');
|
|
14
|
+
const scrollWidthOf = createFieldGetter('scrollWidth');
|
|
15
|
+
const offsetHeightOf = createFieldGetter('offsetHeight');
|
|
16
|
+
const offsetWidthOf = createFieldGetter('offsetWidth');
|
|
17
|
+
const styleOf = createFieldGetter('style');
|
|
18
|
+
const scrollBarModeOf = createFieldGetter('scrollBarMode');
|
|
19
|
+
const onScroll = createFieldGetter('onScroll');
|
|
20
|
+
const horizontalScrollBarModeOf = createFieldGetter('horizontalScrollBarMode');
|
|
21
|
+
class AbstractScrollable extends PureComponent {
|
|
22
|
+
}
|
|
23
|
+
class Scrollable extends AbstractScrollable {
|
|
24
|
+
constructor(properties) {
|
|
25
|
+
super(properties);
|
|
26
|
+
const that = this;
|
|
27
|
+
that.state = {};
|
|
28
|
+
const props = propsGetter(that);
|
|
29
|
+
const status = stateGS(that);
|
|
30
|
+
const statusH = stateGS(that);
|
|
31
|
+
const viewportRef = createRef();
|
|
32
|
+
const scrollbarRef = createRef();
|
|
33
|
+
const horizontalScrollbarRef = createRef();
|
|
34
|
+
const thumbRef = createRef();
|
|
35
|
+
const horizontalThumbRef = createRef();
|
|
36
|
+
let resizeInterval;
|
|
37
|
+
let initTimeout;
|
|
38
|
+
const clear = () => {
|
|
39
|
+
clearInterval(resizeInterval);
|
|
40
|
+
clearTimeout(initTimeout);
|
|
41
|
+
};
|
|
42
|
+
const init = () => {
|
|
43
|
+
clear();
|
|
44
|
+
if (scrollBarModeOf(props()) === SCROLLBAR_MODE_HIDDEN && horizontalScrollBarModeOf(props()) === SCROLLBAR_MODE_HIDDEN) {
|
|
45
|
+
status(WITHOUT_SCROLL);
|
|
46
|
+
statusH(WITHOUT_SCROLL);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const viewport = viewportRef();
|
|
50
|
+
const scrollbar = scrollbarRef();
|
|
51
|
+
const scrollbarH = horizontalScrollbarRef();
|
|
52
|
+
const container = that.el;
|
|
53
|
+
const thumb = thumbRef();
|
|
54
|
+
const thumbH = horizontalThumbRef();
|
|
55
|
+
let scrolling = '';
|
|
56
|
+
let scrolledToBottom = false;
|
|
57
|
+
let scrolledToTop = false;
|
|
58
|
+
let adjustedScrollWidth = false;
|
|
59
|
+
let lastY = 0;
|
|
60
|
+
let lastX = 0;
|
|
61
|
+
let ratio = 0;
|
|
62
|
+
let ratioH = 0;
|
|
63
|
+
const onScrollListener = onScroll(props());
|
|
64
|
+
viewport.onscroll = (e) => {
|
|
65
|
+
const scrollHeight = scrollHeightOf(viewport);
|
|
66
|
+
const offsetHeight = offsetHeightOf(viewport);
|
|
67
|
+
const scrollWidth = scrollWidthOf(viewport);
|
|
68
|
+
const offsetWidth = offsetWidthOf(viewport);
|
|
69
|
+
const scrollbarHeight = offsetHeightOf(scrollbar);
|
|
70
|
+
const scrollbarWidth = offsetWidthOf(scrollbarH);
|
|
71
|
+
let position = __scrollTop(viewport) / (scrollHeight - offsetHeight);
|
|
72
|
+
const positionH = __scrollLeft(viewport) / (scrollWidth - offsetWidth);
|
|
73
|
+
if (position > 1) {
|
|
74
|
+
viewport.scrollTop = scrollHeight - offsetHeight;
|
|
75
|
+
position = 1;
|
|
76
|
+
}
|
|
77
|
+
styleOf(thumb).top = (position * (scrollbarHeight - offsetHeightOf(thumb))) + 'px';
|
|
78
|
+
styleOf(thumbH).left = (positionH * (scrollbarWidth - offsetWidthOf(thumbH))) + 'px';
|
|
79
|
+
if (position >= 0.98) {
|
|
80
|
+
!scrolledToBottom && orNoop(props().onScrolledToBottom)();
|
|
81
|
+
scrolledToBottom = true;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
scrolledToBottom = false;
|
|
85
|
+
}
|
|
86
|
+
if (position <= 0.02) {
|
|
87
|
+
!scrolledToTop && orNoop(props().onScrolledToTop)();
|
|
88
|
+
scrolledToTop = true;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
scrolledToTop = false;
|
|
92
|
+
}
|
|
93
|
+
onScrollListener && onScrollListener(e);
|
|
94
|
+
};
|
|
95
|
+
const reset = () => {
|
|
96
|
+
removeEventListener(WINDOW, 'mouseup', reset);
|
|
97
|
+
removeEventListener(WINDOW, 'mousemove', moveListener);
|
|
98
|
+
__style(viewport).scrollBehavior = '';
|
|
99
|
+
scrolling = '';
|
|
100
|
+
};
|
|
101
|
+
const moveListener = (e) => {
|
|
102
|
+
if (!scrolling)
|
|
103
|
+
return;
|
|
104
|
+
if (scrolling === 'v') {
|
|
105
|
+
viewport.scrollTop += (e.clientY - lastY) * ratio;
|
|
106
|
+
lastY = e.clientY;
|
|
107
|
+
}
|
|
108
|
+
else if (scrolling === 'h') {
|
|
109
|
+
viewport.scrollLeft += (e.clientX - lastX) * ratioH;
|
|
110
|
+
lastX = e.clientX;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
thumb.onmousedown = (e) => {
|
|
114
|
+
lastY = e.clientY;
|
|
115
|
+
scrolling = 'v';
|
|
116
|
+
ratio = scrollHeightOf(viewport) / offsetHeightOf(viewport);
|
|
117
|
+
__style(viewport).scrollBehavior = 'unset';
|
|
118
|
+
addEventListener(WINDOW, 'mouseup', reset);
|
|
119
|
+
addEventListener(WINDOW, 'mousemove', moveListener);
|
|
120
|
+
};
|
|
121
|
+
thumb.ondragstart = preventDefault;
|
|
122
|
+
thumb.onmouseup = reset;
|
|
123
|
+
thumbH.onmousedown = (e) => {
|
|
124
|
+
lastX = e.clientX;
|
|
125
|
+
scrolling = 'h';
|
|
126
|
+
ratioH = scrollWidthOf(viewport) / offsetWidthOf(viewport);
|
|
127
|
+
__style(viewport).scrollBehavior = 'unset';
|
|
128
|
+
addEventListener(WINDOW, 'mouseup', reset);
|
|
129
|
+
addEventListener(WINDOW, 'mousemove', moveListener);
|
|
130
|
+
};
|
|
131
|
+
thumbH.ondragstart = preventDefault;
|
|
132
|
+
thumbH.onmouseup = reset;
|
|
133
|
+
scrollbar.onclick = (e) => {
|
|
134
|
+
if (__target(e) === scrollbar) {
|
|
135
|
+
let thumbPosition = parseInt(__top(styleOf(thumb)));
|
|
136
|
+
viewport.scrollTop += offsetHeightOf(viewport) * 0.9 * (e.offsetY < thumbPosition ? -1 : 1);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
scrollbarH.onclick = (e) => {
|
|
140
|
+
if (__target(e) === scrollbarH) {
|
|
141
|
+
let thumbPosition = parseInt(__left(styleOf(thumbH)));
|
|
142
|
+
viewport.scrollLeft += offsetWidthOf(viewport) * 0.9 * (e.offsetX < thumbPosition ? -1 : 1);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const adjustScrollWidth = () => {
|
|
146
|
+
if (NATIVE_SCROLL_WIDTH < 0) {
|
|
147
|
+
NATIVE_SCROLL_WIDTH = viewport.offsetWidth - __clientWidth(viewport);
|
|
148
|
+
if (NATIVE_SCROLL_WIDTH === 0 && scrollHeightOf(viewport) !== offsetHeightOf(viewport)) {
|
|
149
|
+
NATIVE_SCROLL_WIDTH = -1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (NATIVE_SCROLL_HEIGHT < 0) {
|
|
153
|
+
NATIVE_SCROLL_HEIGHT = viewport.offsetHeight - __clientHeight(viewport);
|
|
154
|
+
if (NATIVE_SCROLL_HEIGHT === 0 && scrollWidthOf(viewport) !== offsetWidthOf(viewport)) {
|
|
155
|
+
NATIVE_SCROLL_HEIGHT = -1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (!adjustedScrollWidth) {
|
|
159
|
+
if (NATIVE_SCROLL_WIDTH >= 0 && status() !== WITHOUT_SCROLL) {
|
|
160
|
+
styleOf(viewport).paddingRight = (NATIVE_SCROLL_WIDTH) + __clientWidth(scrollbar) + 'px';
|
|
161
|
+
styleOf(viewport).marginRight = -(NATIVE_SCROLL_WIDTH) - __clientWidth(scrollbar) + 'px';
|
|
162
|
+
}
|
|
163
|
+
if (NATIVE_SCROLL_HEIGHT >= 0 && statusH() !== WITHOUT_SCROLL) {
|
|
164
|
+
styleOf(viewport).paddingBottom = (NATIVE_SCROLL_HEIGHT) + __clientHeight(scrollbarH) + 'px';
|
|
165
|
+
styleOf(viewport).marginBottom = -(NATIVE_SCROLL_HEIGHT) - __clientHeight(scrollbarH) + 'px';
|
|
166
|
+
}
|
|
167
|
+
adjustedScrollWidth = true;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
adjustScrollWidth();
|
|
171
|
+
const showScrollbar = (scrollbar, viewport, adjustScrollWidth) => {
|
|
172
|
+
styleOf(scrollbar).visibility = 'inherit';
|
|
173
|
+
styleOf(scrollbar).bottom = '0'; //enable scrollbar
|
|
174
|
+
styleOf(viewport).overflowY = '';
|
|
175
|
+
adjustScrollWidth();
|
|
176
|
+
status() !== WITH_SCROLL && status(WITH_SCROLL);
|
|
177
|
+
};
|
|
178
|
+
const hideScrollbar = (scrollbar, viewport) => {
|
|
179
|
+
styleOf(scrollbar).visibility = 'hidden'; //disable scrollbar
|
|
180
|
+
styleOf(viewport).overflowY = 'inherit';
|
|
181
|
+
styleOf(viewport).paddingRight = '0';
|
|
182
|
+
styleOf(viewport).marginRight = '0';
|
|
183
|
+
status() !== WITHOUT_SCROLL && status(WITHOUT_SCROLL);
|
|
184
|
+
};
|
|
185
|
+
const showHorizontalScrollbar = (scrollbar, viewport, adjustScrollWidth) => {
|
|
186
|
+
styleOf(scrollbar).visibility = 'inherit';
|
|
187
|
+
styleOf(scrollbar).right = '0'; //enable scrollbar
|
|
188
|
+
styleOf(viewport).overflowX = '';
|
|
189
|
+
adjustScrollWidth();
|
|
190
|
+
statusH() !== WITH_SCROLL && statusH(WITH_SCROLL);
|
|
191
|
+
};
|
|
192
|
+
const hideHorizontalScrollbar = (scrollbar, viewport) => {
|
|
193
|
+
styleOf(scrollbar).visibility = 'hidden'; //disable scrollbar
|
|
194
|
+
styleOf(viewport).overflowX = 'inherit';
|
|
195
|
+
styleOf(viewport).paddingBottom = '0';
|
|
196
|
+
styleOf(viewport).marginBottom = '0';
|
|
197
|
+
statusH() !== WITHOUT_SCROLL && statusH(WITHOUT_SCROLL);
|
|
198
|
+
};
|
|
199
|
+
const updateVerticalScrollbar = () => {
|
|
200
|
+
const scrollHeight = scrollHeightOf(viewport);
|
|
201
|
+
const scrollbarHeight = offsetHeightOf(scrollbar);
|
|
202
|
+
const containerHeight = offsetHeightOf(container);
|
|
203
|
+
!adjustedScrollWidth && adjustScrollWidth();
|
|
204
|
+
const newRatio = scrollHeight / scrollbarHeight;
|
|
205
|
+
if ((ratio === newRatio && Number.isFinite(newRatio)) || Number.isNaN(newRatio))
|
|
206
|
+
return;
|
|
207
|
+
const offsetHeight = offsetHeightOf(viewport);
|
|
208
|
+
const horizontalScrollBarOffset = statusH() !== WITHOUT_SCROLL ? __clientHeight(scrollbarH) + Math.max(NATIVE_SCROLL_HEIGHT, 0) : 0;
|
|
209
|
+
let containerOffsetHeight = containerHeight + horizontalScrollBarOffset;
|
|
210
|
+
if (containerOffsetHeight === scrollHeight && status() === WITHOUT_SCROLL) {
|
|
211
|
+
ratio = newRatio;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (props().autoScrollTop && scrollHeight - offsetHeight - __scrollTop(viewport) <= 20 && newRatio < ratio && Number.isFinite(newRatio) && Number.isFinite(ratio)) {
|
|
215
|
+
viewport.scrollTop = 0; // scroll to top if scrollbar gets smaller
|
|
216
|
+
}
|
|
217
|
+
ratio = newRatio;
|
|
218
|
+
if (newRatio > 1.02)
|
|
219
|
+
styleOf(thumb).height = (scrollbarHeight / newRatio) + 'px';
|
|
220
|
+
styleOf(container).height = scrollHeight - horizontalScrollBarOffset + 'px';
|
|
221
|
+
containerOffsetHeight = containerHeight + horizontalScrollBarOffset;
|
|
222
|
+
if (scrollBarModeOf(props()) === SCROLLBAR_MODE_HIDDEN) {
|
|
223
|
+
if (status() !== WITHOUT_SCROLL)
|
|
224
|
+
hideScrollbar(scrollbar, viewport);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (containerOffsetHeight < scrollHeight) {
|
|
228
|
+
adjustedScrollWidth = false;
|
|
229
|
+
showScrollbar(scrollbar, viewport, adjustScrollWidth);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
hideScrollbar(scrollbar, viewport);
|
|
233
|
+
}
|
|
234
|
+
scrolledToBottom = false;
|
|
235
|
+
scrolledToTop = false;
|
|
236
|
+
const position = __scrollTop(viewport) / (scrollHeight - offsetHeight);
|
|
237
|
+
styleOf(thumb).top = (position * (scrollbarHeight - offsetHeightOf(thumb))) + 'px';
|
|
238
|
+
};
|
|
239
|
+
const updateHorizontalScrollbar = () => {
|
|
240
|
+
const scrollWidth = scrollWidthOf(viewport);
|
|
241
|
+
const scrollbarWidth = offsetWidthOf(scrollbarH);
|
|
242
|
+
const containerWidth = offsetWidthOf(container);
|
|
243
|
+
!adjustedScrollWidth && adjustScrollWidth();
|
|
244
|
+
const newRatio = scrollWidth / scrollbarWidth;
|
|
245
|
+
if ((ratioH === newRatio && Number.isFinite(newRatio)) || Number.isNaN(newRatio))
|
|
246
|
+
return;
|
|
247
|
+
const offsetWidth = offsetWidthOf(viewport);
|
|
248
|
+
const verticalScrollBarOffset = status() !== WITHOUT_SCROLL ? __clientWidth(scrollbar) + Math.max(NATIVE_SCROLL_WIDTH, 0) : 0;
|
|
249
|
+
ratioH = newRatio;
|
|
250
|
+
let containerOffsetWidth = containerWidth + verticalScrollBarOffset;
|
|
251
|
+
if (containerOffsetWidth === scrollWidth && statusH() === WITHOUT_SCROLL)
|
|
252
|
+
return;
|
|
253
|
+
if (newRatio > 1.02)
|
|
254
|
+
styleOf(thumbH).width = (scrollbarWidth / newRatio) + 'px';
|
|
255
|
+
if (horizontalScrollBarModeOf(props()) === SCROLLBAR_MODE_HIDDEN) {
|
|
256
|
+
if (statusH() !== WITHOUT_SCROLL)
|
|
257
|
+
hideHorizontalScrollbar(scrollbarH, viewport);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
styleOf(container).width = (scrollWidth - verticalScrollBarOffset) + 'px';
|
|
261
|
+
containerOffsetWidth = containerWidth + verticalScrollBarOffset;
|
|
262
|
+
if (containerOffsetWidth < scrollWidth) {
|
|
263
|
+
adjustedScrollWidth = false;
|
|
264
|
+
showHorizontalScrollbar(scrollbarH, viewport, adjustScrollWidth);
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
hideHorizontalScrollbar(scrollbarH, viewport);
|
|
268
|
+
}
|
|
269
|
+
const position = __scrollLeft(viewport) / (scrollWidth - offsetWidth);
|
|
270
|
+
styleOf(thumbH).left = (position * (scrollbarWidth - offsetWidthOf(thumbH))) + 'px';
|
|
271
|
+
};
|
|
272
|
+
let update;
|
|
273
|
+
let sbm = scrollBarModeOf(props());
|
|
274
|
+
let hsbm = horizontalScrollBarModeOf(props());
|
|
275
|
+
if (sbm !== SCROLLBAR_RESIZE_DISABLED && hsbm !== SCROLLBAR_RESIZE_DISABLED) {
|
|
276
|
+
update = () => {
|
|
277
|
+
updateVerticalScrollbar();
|
|
278
|
+
updateHorizontalScrollbar();
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
else if (sbm !== SCROLLBAR_RESIZE_DISABLED)
|
|
282
|
+
update = updateVerticalScrollbar;
|
|
283
|
+
else if (hsbm !== SCROLLBAR_RESIZE_DISABLED)
|
|
284
|
+
update = updateHorizontalScrollbar;
|
|
285
|
+
if (update) {
|
|
286
|
+
initTimeout = setTimeout(() => {
|
|
287
|
+
resizeInterval = setInterval(update, 16);
|
|
288
|
+
}, 200);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
that[ReactConstants[0]] = init;
|
|
292
|
+
that[ReactConstants[1]] = clear;
|
|
293
|
+
that[ReactConstants[2]] = (prevProps) => {
|
|
294
|
+
if (scrollBarModeOf(props()) !== scrollBarModeOf(prevProps))
|
|
295
|
+
init();
|
|
296
|
+
else if (onScroll(props()) !== onScroll(prevProps))
|
|
297
|
+
init();
|
|
298
|
+
};
|
|
299
|
+
that.setScroll = (y) => {
|
|
300
|
+
viewportRef().scrollTop = y;
|
|
301
|
+
};
|
|
302
|
+
that.getScroll = () => __scrollTop(viewportRef());
|
|
303
|
+
that.getScrollHeight = () => scrollHeightOf(viewportRef());
|
|
304
|
+
that.getHeight = () => that.el.clientHeight;
|
|
305
|
+
that[ReactConstants[3]] = () => {
|
|
306
|
+
const _props = props();
|
|
307
|
+
const { className, children } = _props;
|
|
308
|
+
return (jsxRuntime_1("div", __extends({ [ReactConstants[5]]: classNames('Scrollable', className, status() || WITH_SCROLL, statusH() + '-horizontal'), style: styleOf(_props), ref: ref('el', this) }, { [ReactConstants[4]]: [jsxRuntime_2("div", __extends({ [ReactConstants[5]]: "viewport", ref: viewportRef }, { [ReactConstants[4]]: children })), jsxRuntime_2("div", __extends({ [ReactConstants[5]]: classNames('scrollbar', scrollBarModeOf(_props) || SCROLLBAR_MODE_AUTO), ref: scrollbarRef }, { [ReactConstants[4]]: jsxRuntime_2("div", { [ReactConstants[5]]: "thumb", ref: thumbRef }) })), jsxRuntime_2("div", __extends({ [ReactConstants[5]]: classNames('scrollbar horizontal', horizontalScrollBarModeOf(_props)), ref: horizontalScrollbarRef }, { [ReactConstants[4]]: jsxRuntime_2("div", { [ReactConstants[5]]: "thumb", ref: horizontalThumbRef }) }))] })));
|
|
272
309
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
initTimeout = setTimeout(function () {
|
|
276
|
-
resizeInterval = setInterval(update, 50);
|
|
277
|
-
}, 200);
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
that[ReactConstants[0]] = init;
|
|
281
|
-
that[ReactConstants[1]] = clear;
|
|
282
|
-
that[ReactConstants[2]] = function (prevProps) {
|
|
283
|
-
if (scrollBarModeOf(props()) !== scrollBarModeOf(prevProps)) init();else if (onScroll(props()) !== onScroll(prevProps)) init();
|
|
284
|
-
};
|
|
285
|
-
that.setScroll = function (y) {
|
|
286
|
-
viewportRef().scrollTop = y;
|
|
287
|
-
};
|
|
288
|
-
that.getScroll = function () {
|
|
289
|
-
return __scrollTop(viewportRef());
|
|
290
|
-
};
|
|
291
|
-
that.getScrollHeight = function () {
|
|
292
|
-
return scrollHeightOf(viewportRef());
|
|
293
|
-
};
|
|
294
|
-
that.getHeight = function () {
|
|
295
|
-
return that.el.clientHeight;
|
|
296
|
-
};
|
|
297
|
-
that[ReactConstants[3]] = function () {
|
|
298
|
-
var _props = props();
|
|
299
|
-
var className = _props[ReactConstants[5]],
|
|
300
|
-
children = _props[ReactConstants[4]];
|
|
301
|
-
return ReactCreateElement("div", {
|
|
302
|
-
[ReactConstants[5]]: classNames('Scrollable', className, status() || WITH_SCROLL, statusH() + '-horizontal'),
|
|
303
|
-
style: styleOf(_props),
|
|
304
|
-
ref: ref('el', _assertThisInitialized(_this))
|
|
305
|
-
}, ReactCreateElement("div", {
|
|
306
|
-
[ReactConstants[5]]: "viewport",
|
|
307
|
-
ref: viewportRef
|
|
308
|
-
}, children), ReactCreateElement("div", {
|
|
309
|
-
[ReactConstants[5]]: classNames('scrollbar', scrollBarModeOf(_props) || SCROLLBAR_MODE_AUTO),
|
|
310
|
-
ref: scrollbarRef
|
|
311
|
-
}, ReactCreateElement("div", {
|
|
312
|
-
[ReactConstants[5]]: "thumb",
|
|
313
|
-
ref: thumbRef
|
|
314
|
-
})), ReactCreateElement("div", {
|
|
315
|
-
[ReactConstants[5]]: classNames('scrollbar horizontal', horizontalScrollBarModeOf(_props)),
|
|
316
|
-
ref: horizontalScrollbarRef
|
|
317
|
-
}, ReactCreateElement("div", {
|
|
318
|
-
[ReactConstants[5]]: "thumb",
|
|
319
|
-
ref: horizontalThumbRef
|
|
320
|
-
})));
|
|
321
|
-
};
|
|
322
|
-
return _this;
|
|
323
|
-
}
|
|
324
|
-
return _createClass(Scrollable);
|
|
325
|
-
}(PureComponent);
|
|
326
|
-
var Scrollable$1 = Scrollable;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
327
312
|
Scrollable.defaultProps = {
|
|
328
|
-
|
|
329
|
-
|
|
313
|
+
autoScrollTop: true,
|
|
314
|
+
horizontalScrollBarMode: SCROLLBAR_MODE_HIDDEN
|
|
330
315
|
};
|
|
331
316
|
|
|
332
|
-
export { SCROLLBAR_MODE_AUTO, SCROLLBAR_MODE_HIDDEN, SCROLLBAR_RESIZE_DISABLED, Scrollable
|
|
317
|
+
export { SCROLLBAR_MODE_AUTO, SCROLLBAR_MODE_HIDDEN, SCROLLBAR_RESIZE_DISABLED, Scrollable as default };
|
|
333
318
|
//# sourceMappingURL=Scrollable.js.map
|