@fullcalendar/scrollgrid 5.11.3 → 6.0.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/LICENSE.md +5 -5
- package/index.cjs +22 -0
- package/index.d.ts +7 -0
- package/index.global.js +860 -0
- package/index.global.min.js +6 -0
- package/index.js +14 -0
- package/internal.cjs +834 -0
- package/{main.d.ts → internal.d.ts} +4 -13
- package/internal.js +830 -0
- package/package.json +42 -18
- package/main.cjs.js +0 -983
- package/main.global.js +0 -1038
- package/main.global.min.js +0 -6
- package/main.js +0 -975
- package/main.js.map +0 -1
package/main.cjs.js
DELETED
|
@@ -1,983 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
FullCalendar Scheduler v5.11.3
|
|
3
|
-
Docs & License: https://fullcalendar.io/scheduler
|
|
4
|
-
(c) 2022 Adam Shaw
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
-
|
|
10
|
-
var common = require('@fullcalendar/common');
|
|
11
|
-
var premiumCommonPlugin = require('@fullcalendar/premium-common');
|
|
12
|
-
var tslib = require('tslib');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var premiumCommonPlugin__default = /*#__PURE__*/_interopDefaultLegacy(premiumCommonPlugin);
|
|
17
|
-
|
|
18
|
-
var WHEEL_EVENT_NAMES = 'wheel mousewheel DomMouseScroll MozMousePixelScroll'.split(' ');
|
|
19
|
-
/*
|
|
20
|
-
ALSO, with the ability to disable touch
|
|
21
|
-
*/
|
|
22
|
-
var ScrollListener = /** @class */ (function () {
|
|
23
|
-
function ScrollListener(el) {
|
|
24
|
-
var _this = this;
|
|
25
|
-
this.el = el;
|
|
26
|
-
this.emitter = new common.Emitter();
|
|
27
|
-
this.isScrolling = false;
|
|
28
|
-
this.isTouching = false; // user currently has finger down?
|
|
29
|
-
this.isRecentlyWheeled = false;
|
|
30
|
-
this.isRecentlyScrolled = false;
|
|
31
|
-
this.wheelWaiter = new common.DelayedRunner(this._handleWheelWaited.bind(this));
|
|
32
|
-
this.scrollWaiter = new common.DelayedRunner(this._handleScrollWaited.bind(this));
|
|
33
|
-
// Handlers
|
|
34
|
-
// ----------------------------------------------------------------------------------------------
|
|
35
|
-
this.handleScroll = function () {
|
|
36
|
-
_this.startScroll();
|
|
37
|
-
_this.emitter.trigger('scroll', _this.isRecentlyWheeled, _this.isTouching);
|
|
38
|
-
_this.isRecentlyScrolled = true;
|
|
39
|
-
_this.scrollWaiter.request(500);
|
|
40
|
-
};
|
|
41
|
-
// will fire *before* the scroll event is fired (might not cause a scroll)
|
|
42
|
-
this.handleWheel = function () {
|
|
43
|
-
_this.isRecentlyWheeled = true;
|
|
44
|
-
_this.wheelWaiter.request(500);
|
|
45
|
-
};
|
|
46
|
-
// will fire *before* the scroll event is fired (might not cause a scroll)
|
|
47
|
-
this.handleTouchStart = function () {
|
|
48
|
-
_this.isTouching = true;
|
|
49
|
-
};
|
|
50
|
-
this.handleTouchEnd = function () {
|
|
51
|
-
_this.isTouching = false;
|
|
52
|
-
// if the user ended their touch, and the scroll area wasn't moving,
|
|
53
|
-
// we consider this to be the end of the scroll.
|
|
54
|
-
if (!_this.isRecentlyScrolled) {
|
|
55
|
-
_this.endScroll(); // won't fire if already ended
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
el.addEventListener('scroll', this.handleScroll);
|
|
59
|
-
el.addEventListener('touchstart', this.handleTouchStart, { passive: true });
|
|
60
|
-
el.addEventListener('touchend', this.handleTouchEnd);
|
|
61
|
-
for (var _i = 0, WHEEL_EVENT_NAMES_1 = WHEEL_EVENT_NAMES; _i < WHEEL_EVENT_NAMES_1.length; _i++) {
|
|
62
|
-
var eventName = WHEEL_EVENT_NAMES_1[_i];
|
|
63
|
-
el.addEventListener(eventName, this.handleWheel);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
ScrollListener.prototype.destroy = function () {
|
|
67
|
-
var el = this.el;
|
|
68
|
-
el.removeEventListener('scroll', this.handleScroll);
|
|
69
|
-
el.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
|
|
70
|
-
el.removeEventListener('touchend', this.handleTouchEnd);
|
|
71
|
-
for (var _i = 0, WHEEL_EVENT_NAMES_2 = WHEEL_EVENT_NAMES; _i < WHEEL_EVENT_NAMES_2.length; _i++) {
|
|
72
|
-
var eventName = WHEEL_EVENT_NAMES_2[_i];
|
|
73
|
-
el.removeEventListener(eventName, this.handleWheel);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
// Start / Stop
|
|
77
|
-
// ----------------------------------------------------------------------------------------------
|
|
78
|
-
ScrollListener.prototype.startScroll = function () {
|
|
79
|
-
if (!this.isScrolling) {
|
|
80
|
-
this.isScrolling = true;
|
|
81
|
-
this.emitter.trigger('scrollStart', this.isRecentlyWheeled, this.isTouching);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
ScrollListener.prototype.endScroll = function () {
|
|
85
|
-
if (this.isScrolling) {
|
|
86
|
-
this.emitter.trigger('scrollEnd');
|
|
87
|
-
this.isScrolling = false;
|
|
88
|
-
this.isRecentlyScrolled = true;
|
|
89
|
-
this.isRecentlyWheeled = false;
|
|
90
|
-
this.scrollWaiter.clear();
|
|
91
|
-
this.wheelWaiter.clear();
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
ScrollListener.prototype._handleScrollWaited = function () {
|
|
95
|
-
this.isRecentlyScrolled = false;
|
|
96
|
-
// only end the scroll if not currently touching.
|
|
97
|
-
// if touching, the scrolling will end later, on touchend.
|
|
98
|
-
if (!this.isTouching) {
|
|
99
|
-
this.endScroll(); // won't fire if already ended
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
ScrollListener.prototype._handleWheelWaited = function () {
|
|
103
|
-
this.isRecentlyWheeled = false;
|
|
104
|
-
};
|
|
105
|
-
return ScrollListener;
|
|
106
|
-
}());
|
|
107
|
-
|
|
108
|
-
// TODO: assume the el has no borders?
|
|
109
|
-
function getScrollCanvasOrigin(scrollEl) {
|
|
110
|
-
var rect = scrollEl.getBoundingClientRect();
|
|
111
|
-
var edges = common.computeEdges(scrollEl); // TODO: pass in isRtl?
|
|
112
|
-
return {
|
|
113
|
-
left: rect.left + edges.borderLeft + edges.scrollbarLeft - getScrollFromLeftEdge(scrollEl),
|
|
114
|
-
top: rect.top + edges.borderTop - scrollEl.scrollTop,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function getScrollFromLeftEdge(el) {
|
|
118
|
-
var scrollLeft = el.scrollLeft;
|
|
119
|
-
var computedStyles = window.getComputedStyle(el); // TODO: pass in isRtl instead?
|
|
120
|
-
if (computedStyles.direction === 'rtl') {
|
|
121
|
-
switch (getRtlScrollSystem()) {
|
|
122
|
-
case 'negative':
|
|
123
|
-
scrollLeft *= -1; // convert to 'reverse'. fall through...
|
|
124
|
-
case 'reverse': // scrollLeft is distance between scrollframe's right edge scrollcanvas's right edge
|
|
125
|
-
scrollLeft = el.scrollWidth - scrollLeft - el.clientWidth;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return scrollLeft;
|
|
129
|
-
}
|
|
130
|
-
function setScrollFromLeftEdge(el, scrollLeft) {
|
|
131
|
-
var computedStyles = window.getComputedStyle(el); // TODO: pass in isRtl instead?
|
|
132
|
-
if (computedStyles.direction === 'rtl') {
|
|
133
|
-
switch (getRtlScrollSystem()) {
|
|
134
|
-
case 'reverse':
|
|
135
|
-
scrollLeft = el.scrollWidth - scrollLeft;
|
|
136
|
-
break;
|
|
137
|
-
case 'negative':
|
|
138
|
-
scrollLeft = -(el.scrollWidth - scrollLeft);
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
el.scrollLeft = scrollLeft;
|
|
143
|
-
}
|
|
144
|
-
// Horizontal Scroll System Detection
|
|
145
|
-
// ----------------------------------------------------------------------------------------------
|
|
146
|
-
var _rtlScrollSystem;
|
|
147
|
-
function getRtlScrollSystem() {
|
|
148
|
-
return _rtlScrollSystem || (_rtlScrollSystem = detectRtlScrollSystem());
|
|
149
|
-
}
|
|
150
|
-
function detectRtlScrollSystem() {
|
|
151
|
-
var el = document.createElement('div');
|
|
152
|
-
el.style.position = 'absolute';
|
|
153
|
-
el.style.top = '-1000px';
|
|
154
|
-
el.style.width = '1px';
|
|
155
|
-
el.style.height = '1px';
|
|
156
|
-
el.style.overflow = 'scroll';
|
|
157
|
-
el.style.direction = 'rtl';
|
|
158
|
-
el.style.fontSize = '100px';
|
|
159
|
-
el.innerHTML = 'A';
|
|
160
|
-
document.body.appendChild(el);
|
|
161
|
-
var system;
|
|
162
|
-
if (el.scrollLeft > 0) {
|
|
163
|
-
system = 'positive'; // scroll is a positive number from the left edge
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
el.scrollLeft = 1;
|
|
167
|
-
if (el.scrollLeft > 0) {
|
|
168
|
-
system = 'reverse'; // scroll is a positive number from the right edge
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
system = 'negative'; // scroll is a negative number from the right edge
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
common.removeElement(el);
|
|
175
|
-
return system;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
var IS_MS_EDGE = typeof navigator !== 'undefined' && /Edge/.test(navigator.userAgent); // TODO: what about Chromeum-based Edge?
|
|
179
|
-
var STICKY_SELECTOR = '.fc-sticky';
|
|
180
|
-
/*
|
|
181
|
-
useful beyond the native position:sticky for these reasons:
|
|
182
|
-
- support in IE11
|
|
183
|
-
- nice centering support
|
|
184
|
-
|
|
185
|
-
REQUIREMENT: fc-sticky elements, if the fc-sticky className is taken away, should NOT have relative or absolute positioning.
|
|
186
|
-
This is because we attach the coords with JS, and the VDOM might take away the fc-sticky class but doesn't know kill the positioning.
|
|
187
|
-
|
|
188
|
-
TODO: don't query text-align:center. isn't compatible with flexbox centering. instead, check natural X coord within parent container
|
|
189
|
-
*/
|
|
190
|
-
var StickyScrolling = /** @class */ (function () {
|
|
191
|
-
function StickyScrolling(scrollEl, isRtl) {
|
|
192
|
-
var _this = this;
|
|
193
|
-
this.scrollEl = scrollEl;
|
|
194
|
-
this.isRtl = isRtl;
|
|
195
|
-
this.usingRelative = null;
|
|
196
|
-
this.updateSize = function () {
|
|
197
|
-
var scrollEl = _this.scrollEl;
|
|
198
|
-
var els = common.findElements(scrollEl, STICKY_SELECTOR);
|
|
199
|
-
var elGeoms = _this.queryElGeoms(els);
|
|
200
|
-
var viewportWidth = scrollEl.clientWidth;
|
|
201
|
-
var viewportHeight = scrollEl.clientHeight;
|
|
202
|
-
if (_this.usingRelative) {
|
|
203
|
-
var elDestinations = _this.computeElDestinations(elGeoms, viewportWidth); // read before prepPositioning
|
|
204
|
-
assignRelativePositions(els, elGeoms, elDestinations, viewportWidth, viewportHeight);
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
assignStickyPositions(els, elGeoms, viewportWidth);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
this.usingRelative =
|
|
211
|
-
!getStickySupported() || // IE11
|
|
212
|
-
// https://stackoverflow.com/questions/56835658/in-microsoft-edge-sticky-positioning-doesnt-work-when-combined-with-dir-rtl
|
|
213
|
-
(IS_MS_EDGE && isRtl);
|
|
214
|
-
if (this.usingRelative) {
|
|
215
|
-
this.listener = new ScrollListener(scrollEl);
|
|
216
|
-
this.listener.emitter.on('scrollEnd', this.updateSize);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
StickyScrolling.prototype.destroy = function () {
|
|
220
|
-
if (this.listener) {
|
|
221
|
-
this.listener.destroy();
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
StickyScrolling.prototype.queryElGeoms = function (els) {
|
|
225
|
-
var _a = this, scrollEl = _a.scrollEl, isRtl = _a.isRtl;
|
|
226
|
-
var canvasOrigin = getScrollCanvasOrigin(scrollEl);
|
|
227
|
-
var elGeoms = [];
|
|
228
|
-
for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
|
|
229
|
-
var el = els_1[_i];
|
|
230
|
-
var parentBound = common.translateRect(common.computeInnerRect(el.parentNode, true, true), // weird way to call this!!!
|
|
231
|
-
-canvasOrigin.left, -canvasOrigin.top);
|
|
232
|
-
var elRect = el.getBoundingClientRect();
|
|
233
|
-
var computedStyles = window.getComputedStyle(el);
|
|
234
|
-
var textAlign = window.getComputedStyle(el.parentNode).textAlign; // ask the parent
|
|
235
|
-
var naturalBound = null;
|
|
236
|
-
if (textAlign === 'start') {
|
|
237
|
-
textAlign = isRtl ? 'right' : 'left';
|
|
238
|
-
}
|
|
239
|
-
else if (textAlign === 'end') {
|
|
240
|
-
textAlign = isRtl ? 'left' : 'right';
|
|
241
|
-
}
|
|
242
|
-
if (computedStyles.position !== 'sticky') {
|
|
243
|
-
naturalBound = common.translateRect(elRect, -canvasOrigin.left - (parseFloat(computedStyles.left) || 0), // could be 'auto'
|
|
244
|
-
-canvasOrigin.top - (parseFloat(computedStyles.top) || 0));
|
|
245
|
-
}
|
|
246
|
-
elGeoms.push({
|
|
247
|
-
parentBound: parentBound,
|
|
248
|
-
naturalBound: naturalBound,
|
|
249
|
-
elWidth: elRect.width,
|
|
250
|
-
elHeight: elRect.height,
|
|
251
|
-
textAlign: textAlign,
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
return elGeoms;
|
|
255
|
-
};
|
|
256
|
-
// only for IE
|
|
257
|
-
StickyScrolling.prototype.computeElDestinations = function (elGeoms, viewportWidth) {
|
|
258
|
-
var scrollEl = this.scrollEl;
|
|
259
|
-
var viewportTop = scrollEl.scrollTop;
|
|
260
|
-
var viewportLeft = getScrollFromLeftEdge(scrollEl);
|
|
261
|
-
var viewportRight = viewportLeft + viewportWidth;
|
|
262
|
-
return elGeoms.map(function (elGeom) {
|
|
263
|
-
var elWidth = elGeom.elWidth, elHeight = elGeom.elHeight, parentBound = elGeom.parentBound, naturalBound = elGeom.naturalBound;
|
|
264
|
-
var destLeft; // relative to canvas topleft
|
|
265
|
-
var destTop; // "
|
|
266
|
-
switch (elGeom.textAlign) {
|
|
267
|
-
case 'left':
|
|
268
|
-
destLeft = viewportLeft;
|
|
269
|
-
break;
|
|
270
|
-
case 'right':
|
|
271
|
-
destLeft = viewportRight - elWidth;
|
|
272
|
-
break;
|
|
273
|
-
case 'center':
|
|
274
|
-
destLeft = (viewportLeft + viewportRight) / 2 - elWidth / 2; /// noooo, use half-width insteadddddddd
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
destLeft = Math.min(destLeft, parentBound.right - elWidth);
|
|
278
|
-
destLeft = Math.max(destLeft, parentBound.left);
|
|
279
|
-
destTop = viewportTop;
|
|
280
|
-
destTop = Math.min(destTop, parentBound.bottom - elHeight);
|
|
281
|
-
destTop = Math.max(destTop, naturalBound.top); // better to use natural top for upper bound
|
|
282
|
-
return { left: destLeft, top: destTop };
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
|
-
return StickyScrolling;
|
|
286
|
-
}());
|
|
287
|
-
function assignRelativePositions(els, elGeoms, elDestinations, viewportWidth, viewportHeight) {
|
|
288
|
-
els.forEach(function (el, i) {
|
|
289
|
-
var _a = elGeoms[i], naturalBound = _a.naturalBound, parentBound = _a.parentBound;
|
|
290
|
-
var parentWidth = parentBound.right - parentBound.left;
|
|
291
|
-
var parentHeight = parentBound.bottom - parentBound.bottom;
|
|
292
|
-
var left;
|
|
293
|
-
var top;
|
|
294
|
-
if (parentWidth > viewportWidth ||
|
|
295
|
-
parentHeight > viewportHeight) {
|
|
296
|
-
left = elDestinations[i].left - naturalBound.left;
|
|
297
|
-
top = elDestinations[i].top - naturalBound.top;
|
|
298
|
-
}
|
|
299
|
-
else { // if parent container can be completely in view, we don't need stickiness
|
|
300
|
-
left = '';
|
|
301
|
-
top = '';
|
|
302
|
-
}
|
|
303
|
-
common.applyStyle(el, {
|
|
304
|
-
position: 'relative',
|
|
305
|
-
left: left,
|
|
306
|
-
right: -left,
|
|
307
|
-
top: top,
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
function assignStickyPositions(els, elGeoms, viewportWidth) {
|
|
312
|
-
els.forEach(function (el, i) {
|
|
313
|
-
var _a = elGeoms[i], textAlign = _a.textAlign, elWidth = _a.elWidth, parentBound = _a.parentBound;
|
|
314
|
-
var parentWidth = parentBound.right - parentBound.left;
|
|
315
|
-
var left;
|
|
316
|
-
if (textAlign === 'center' &&
|
|
317
|
-
parentWidth > viewportWidth) {
|
|
318
|
-
left = (viewportWidth - elWidth) / 2;
|
|
319
|
-
}
|
|
320
|
-
else { // if parent container can be completely in view, we don't need stickiness
|
|
321
|
-
left = '';
|
|
322
|
-
}
|
|
323
|
-
common.applyStyle(el, {
|
|
324
|
-
left: left,
|
|
325
|
-
right: left,
|
|
326
|
-
top: 0,
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
var _isStickySupported;
|
|
331
|
-
function getStickySupported() {
|
|
332
|
-
if (_isStickySupported == null) {
|
|
333
|
-
_isStickySupported = computeStickySupported();
|
|
334
|
-
}
|
|
335
|
-
return _isStickySupported;
|
|
336
|
-
}
|
|
337
|
-
function computeStickySupported() {
|
|
338
|
-
var el = document.createElement('div');
|
|
339
|
-
el.style.position = 'sticky';
|
|
340
|
-
document.body.appendChild(el);
|
|
341
|
-
var val = window.getComputedStyle(el).position;
|
|
342
|
-
common.removeElement(el);
|
|
343
|
-
return val === 'sticky';
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
var ClippedScroller = /** @class */ (function (_super) {
|
|
347
|
-
tslib.__extends(ClippedScroller, _super);
|
|
348
|
-
function ClippedScroller() {
|
|
349
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
350
|
-
_this.elRef = common.createRef();
|
|
351
|
-
_this.state = {
|
|
352
|
-
xScrollbarWidth: 0,
|
|
353
|
-
yScrollbarWidth: 0,
|
|
354
|
-
};
|
|
355
|
-
_this.handleScroller = function (scroller) {
|
|
356
|
-
_this.scroller = scroller;
|
|
357
|
-
common.setRef(_this.props.scrollerRef, scroller);
|
|
358
|
-
};
|
|
359
|
-
_this.handleSizing = function () {
|
|
360
|
-
var props = _this.props;
|
|
361
|
-
if (props.overflowY === 'scroll-hidden') {
|
|
362
|
-
_this.setState({ yScrollbarWidth: _this.scroller.getYScrollbarWidth() });
|
|
363
|
-
}
|
|
364
|
-
if (props.overflowX === 'scroll-hidden') {
|
|
365
|
-
_this.setState({ xScrollbarWidth: _this.scroller.getXScrollbarWidth() });
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
return _this;
|
|
369
|
-
}
|
|
370
|
-
ClippedScroller.prototype.render = function () {
|
|
371
|
-
var _a = this, props = _a.props, state = _a.state, context = _a.context;
|
|
372
|
-
var isScrollbarOnLeft = context.isRtl && common.getIsRtlScrollbarOnLeft();
|
|
373
|
-
var overcomeLeft = 0;
|
|
374
|
-
var overcomeRight = 0;
|
|
375
|
-
var overcomeBottom = 0;
|
|
376
|
-
if (props.overflowX === 'scroll-hidden') {
|
|
377
|
-
overcomeBottom = state.xScrollbarWidth;
|
|
378
|
-
}
|
|
379
|
-
if (props.overflowY === 'scroll-hidden') {
|
|
380
|
-
if (state.yScrollbarWidth != null) {
|
|
381
|
-
if (isScrollbarOnLeft) {
|
|
382
|
-
overcomeLeft = state.yScrollbarWidth;
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
overcomeRight = state.yScrollbarWidth;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
return (common.createElement("div", { ref: this.elRef, className: 'fc-scroller-harness' + (props.liquid ? ' fc-scroller-harness-liquid' : '') },
|
|
390
|
-
common.createElement(common.Scroller, { ref: this.handleScroller, elRef: this.props.scrollerElRef, overflowX: props.overflowX === 'scroll-hidden' ? 'scroll' : props.overflowX, overflowY: props.overflowY === 'scroll-hidden' ? 'scroll' : props.overflowY, overcomeLeft: overcomeLeft, overcomeRight: overcomeRight, overcomeBottom: overcomeBottom, maxHeight: typeof props.maxHeight === 'number'
|
|
391
|
-
? (props.maxHeight + (props.overflowX === 'scroll-hidden' ? state.xScrollbarWidth : 0))
|
|
392
|
-
: '', liquid: props.liquid, liquidIsAbsolute: true }, props.children)));
|
|
393
|
-
};
|
|
394
|
-
ClippedScroller.prototype.componentDidMount = function () {
|
|
395
|
-
this.handleSizing();
|
|
396
|
-
this.context.addResizeHandler(this.handleSizing);
|
|
397
|
-
};
|
|
398
|
-
ClippedScroller.prototype.componentDidUpdate = function (prevProps) {
|
|
399
|
-
if (!common.isPropsEqual(prevProps, this.props)) { // an external change?
|
|
400
|
-
this.handleSizing();
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
ClippedScroller.prototype.componentWillUnmount = function () {
|
|
404
|
-
this.context.removeResizeHandler(this.handleSizing);
|
|
405
|
-
};
|
|
406
|
-
ClippedScroller.prototype.needsXScrolling = function () {
|
|
407
|
-
return this.scroller.needsXScrolling();
|
|
408
|
-
};
|
|
409
|
-
ClippedScroller.prototype.needsYScrolling = function () {
|
|
410
|
-
return this.scroller.needsYScrolling();
|
|
411
|
-
};
|
|
412
|
-
return ClippedScroller;
|
|
413
|
-
}(common.BaseComponent));
|
|
414
|
-
|
|
415
|
-
var ScrollSyncer = /** @class */ (function () {
|
|
416
|
-
function ScrollSyncer(isVertical, scrollEls) {
|
|
417
|
-
var _this = this;
|
|
418
|
-
this.isVertical = isVertical;
|
|
419
|
-
this.scrollEls = scrollEls;
|
|
420
|
-
this.isPaused = false;
|
|
421
|
-
this.scrollListeners = scrollEls.map(function (el) { return _this.bindScroller(el); });
|
|
422
|
-
}
|
|
423
|
-
ScrollSyncer.prototype.destroy = function () {
|
|
424
|
-
for (var _i = 0, _a = this.scrollListeners; _i < _a.length; _i++) {
|
|
425
|
-
var scrollListener = _a[_i];
|
|
426
|
-
scrollListener.destroy();
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
ScrollSyncer.prototype.bindScroller = function (el) {
|
|
430
|
-
var _this = this;
|
|
431
|
-
var _a = this, scrollEls = _a.scrollEls, isVertical = _a.isVertical;
|
|
432
|
-
var scrollListener = new ScrollListener(el);
|
|
433
|
-
var onScroll = function (isWheel, isTouch) {
|
|
434
|
-
if (!_this.isPaused) {
|
|
435
|
-
if (!_this.masterEl || (_this.masterEl !== el && (isWheel || isTouch))) {
|
|
436
|
-
_this.assignMaster(el);
|
|
437
|
-
}
|
|
438
|
-
if (_this.masterEl === el) { // dealing with current
|
|
439
|
-
for (var _i = 0, scrollEls_1 = scrollEls; _i < scrollEls_1.length; _i++) {
|
|
440
|
-
var otherEl = scrollEls_1[_i];
|
|
441
|
-
if (otherEl !== el) {
|
|
442
|
-
if (isVertical) {
|
|
443
|
-
otherEl.scrollTop = el.scrollTop;
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
otherEl.scrollLeft = el.scrollLeft;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
var onScrollEnd = function () {
|
|
454
|
-
if (_this.masterEl === el) {
|
|
455
|
-
_this.masterEl = null;
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
scrollListener.emitter.on('scroll', onScroll);
|
|
459
|
-
scrollListener.emitter.on('scrollEnd', onScrollEnd);
|
|
460
|
-
return scrollListener;
|
|
461
|
-
};
|
|
462
|
-
ScrollSyncer.prototype.assignMaster = function (el) {
|
|
463
|
-
this.masterEl = el;
|
|
464
|
-
for (var _i = 0, _a = this.scrollListeners; _i < _a.length; _i++) {
|
|
465
|
-
var scrollListener = _a[_i];
|
|
466
|
-
if (scrollListener.el !== el) {
|
|
467
|
-
scrollListener.endScroll(); // to prevent residual scrolls from reclaiming master
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
/*
|
|
472
|
-
will normalize the scrollLeft value
|
|
473
|
-
*/
|
|
474
|
-
ScrollSyncer.prototype.forceScrollLeft = function (scrollLeft) {
|
|
475
|
-
this.isPaused = true;
|
|
476
|
-
for (var _i = 0, _a = this.scrollListeners; _i < _a.length; _i++) {
|
|
477
|
-
var listener = _a[_i];
|
|
478
|
-
setScrollFromLeftEdge(listener.el, scrollLeft);
|
|
479
|
-
}
|
|
480
|
-
this.isPaused = false;
|
|
481
|
-
};
|
|
482
|
-
ScrollSyncer.prototype.forceScrollTop = function (top) {
|
|
483
|
-
this.isPaused = true;
|
|
484
|
-
for (var _i = 0, _a = this.scrollListeners; _i < _a.length; _i++) {
|
|
485
|
-
var listener = _a[_i];
|
|
486
|
-
listener.el.scrollTop = top;
|
|
487
|
-
}
|
|
488
|
-
this.isPaused = false;
|
|
489
|
-
};
|
|
490
|
-
return ScrollSyncer;
|
|
491
|
-
}());
|
|
492
|
-
|
|
493
|
-
/*
|
|
494
|
-
TODO: make <ScrollGridSection> subcomponent
|
|
495
|
-
NOTE: doesn't support collapsibleWidth (which is sortof a hack anyway)
|
|
496
|
-
*/
|
|
497
|
-
var ScrollGrid = /** @class */ (function (_super) {
|
|
498
|
-
tslib.__extends(ScrollGrid, _super);
|
|
499
|
-
function ScrollGrid() {
|
|
500
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
501
|
-
_this.compileColGroupStats = common.memoizeArraylike(compileColGroupStat, isColGroupStatsEqual);
|
|
502
|
-
_this.renderMicroColGroups = common.memoizeArraylike(common.renderMicroColGroup); // yucky to memoize VNodes, but much more efficient for consumers
|
|
503
|
-
_this.clippedScrollerRefs = new common.RefMap();
|
|
504
|
-
// doesn't hold non-scrolling els used just for padding
|
|
505
|
-
_this.scrollerElRefs = new common.RefMap(_this._handleScrollerEl.bind(_this));
|
|
506
|
-
_this.chunkElRefs = new common.RefMap(_this._handleChunkEl.bind(_this));
|
|
507
|
-
_this.stickyScrollings = [];
|
|
508
|
-
_this.scrollSyncersBySection = {};
|
|
509
|
-
_this.scrollSyncersByColumn = {};
|
|
510
|
-
// for row-height-syncing
|
|
511
|
-
_this.rowUnstableMap = new Map(); // no need to groom. always self-cancels
|
|
512
|
-
_this.rowInnerMaxHeightMap = new Map();
|
|
513
|
-
_this.anyRowHeightsChanged = false;
|
|
514
|
-
_this.recentSizingCnt = 0;
|
|
515
|
-
_this.state = {
|
|
516
|
-
shrinkWidths: [],
|
|
517
|
-
forceYScrollbars: false,
|
|
518
|
-
forceXScrollbars: false,
|
|
519
|
-
scrollerClientWidths: {},
|
|
520
|
-
scrollerClientHeights: {},
|
|
521
|
-
sectionRowMaxHeights: [],
|
|
522
|
-
};
|
|
523
|
-
_this.handleSizing = function (isForcedResize, sectionRowMaxHeightsChanged) {
|
|
524
|
-
if (!_this.allowSizing()) {
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
if (!sectionRowMaxHeightsChanged) { // something else changed, probably external
|
|
528
|
-
_this.anyRowHeightsChanged = true;
|
|
529
|
-
}
|
|
530
|
-
var otherState = {};
|
|
531
|
-
// if reacting to self-change of sectionRowMaxHeightsChanged, or not stable, don't do anything
|
|
532
|
-
if (isForcedResize || (!sectionRowMaxHeightsChanged && !_this.rowUnstableMap.size)) {
|
|
533
|
-
otherState.sectionRowMaxHeights = _this.computeSectionRowMaxHeights();
|
|
534
|
-
}
|
|
535
|
-
_this.setState(tslib.__assign(tslib.__assign({ shrinkWidths: _this.computeShrinkWidths() }, _this.computeScrollerDims()), otherState), function () {
|
|
536
|
-
if (!_this.rowUnstableMap.size) {
|
|
537
|
-
_this.updateStickyScrolling(); // needs to happen AFTER final positioning committed to DOM
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
_this.handleRowHeightChange = function (rowEl, isStable) {
|
|
542
|
-
var _a = _this, rowUnstableMap = _a.rowUnstableMap, rowInnerMaxHeightMap = _a.rowInnerMaxHeightMap;
|
|
543
|
-
if (!isStable) {
|
|
544
|
-
rowUnstableMap.set(rowEl, true);
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
rowUnstableMap.delete(rowEl);
|
|
548
|
-
var innerMaxHeight = getRowInnerMaxHeight(rowEl);
|
|
549
|
-
if (!rowInnerMaxHeightMap.has(rowEl) || rowInnerMaxHeightMap.get(rowEl) !== innerMaxHeight) {
|
|
550
|
-
rowInnerMaxHeightMap.set(rowEl, innerMaxHeight);
|
|
551
|
-
_this.anyRowHeightsChanged = true;
|
|
552
|
-
}
|
|
553
|
-
if (!rowUnstableMap.size && _this.anyRowHeightsChanged) {
|
|
554
|
-
_this.anyRowHeightsChanged = false;
|
|
555
|
-
_this.setState({
|
|
556
|
-
sectionRowMaxHeights: _this.computeSectionRowMaxHeights(),
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
return _this;
|
|
562
|
-
}
|
|
563
|
-
ScrollGrid.prototype.render = function () {
|
|
564
|
-
var _a = this, props = _a.props, state = _a.state, context = _a.context;
|
|
565
|
-
var shrinkWidths = state.shrinkWidths;
|
|
566
|
-
var colGroupStats = this.compileColGroupStats(props.colGroups.map(function (colGroup) { return [colGroup]; }));
|
|
567
|
-
var microColGroupNodes = this.renderMicroColGroups(colGroupStats.map(function (stat, i) { return [stat.cols, shrinkWidths[i]]; }));
|
|
568
|
-
var classNames = common.getScrollGridClassNames(props.liquid, context);
|
|
569
|
-
var _b = this.getDims(); _b[0]; _b[1];
|
|
570
|
-
// TODO: make DRY
|
|
571
|
-
var sectionConfigs = props.sections;
|
|
572
|
-
var configCnt = sectionConfigs.length;
|
|
573
|
-
var configI = 0;
|
|
574
|
-
var currentConfig;
|
|
575
|
-
var headSectionNodes = [];
|
|
576
|
-
var bodySectionNodes = [];
|
|
577
|
-
var footSectionNodes = [];
|
|
578
|
-
while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
|
|
579
|
-
headSectionNodes.push(this.renderSection(currentConfig, configI, colGroupStats, microColGroupNodes, state.sectionRowMaxHeights, true));
|
|
580
|
-
configI += 1;
|
|
581
|
-
}
|
|
582
|
-
while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
|
|
583
|
-
bodySectionNodes.push(this.renderSection(currentConfig, configI, colGroupStats, microColGroupNodes, state.sectionRowMaxHeights, false));
|
|
584
|
-
configI += 1;
|
|
585
|
-
}
|
|
586
|
-
while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
|
|
587
|
-
footSectionNodes.push(this.renderSection(currentConfig, configI, colGroupStats, microColGroupNodes, state.sectionRowMaxHeights, true));
|
|
588
|
-
configI += 1;
|
|
589
|
-
}
|
|
590
|
-
var isBuggy = !common.getCanVGrowWithinCell(); // see NOTE in SimpleScrollGrid
|
|
591
|
-
var roleAttrs = { role: 'rowgroup' };
|
|
592
|
-
return common.createElement('table', {
|
|
593
|
-
ref: props.elRef,
|
|
594
|
-
role: 'grid',
|
|
595
|
-
className: classNames.join(' '),
|
|
596
|
-
}, renderMacroColGroup(colGroupStats, shrinkWidths), Boolean(!isBuggy && headSectionNodes.length) && common.createElement.apply(void 0, tslib.__spreadArray(['thead', roleAttrs], headSectionNodes)), Boolean(!isBuggy && bodySectionNodes.length) && common.createElement.apply(void 0, tslib.__spreadArray(['tbody', roleAttrs], bodySectionNodes)), Boolean(!isBuggy && footSectionNodes.length) && common.createElement.apply(void 0, tslib.__spreadArray(['tfoot', roleAttrs], footSectionNodes)), isBuggy && common.createElement.apply(void 0, tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray(['tbody', roleAttrs], headSectionNodes), bodySectionNodes), footSectionNodes)));
|
|
597
|
-
};
|
|
598
|
-
ScrollGrid.prototype.renderSection = function (sectionConfig, sectionIndex, colGroupStats, microColGroupNodes, sectionRowMaxHeights, isHeader) {
|
|
599
|
-
var _this = this;
|
|
600
|
-
if ('outerContent' in sectionConfig) {
|
|
601
|
-
return (common.createElement(common.Fragment, { key: sectionConfig.key }, sectionConfig.outerContent));
|
|
602
|
-
}
|
|
603
|
-
return (common.createElement("tr", { key: sectionConfig.key, role: "presentation", className: common.getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, sectionConfig.chunks.map(function (chunkConfig, i) { return _this.renderChunk(sectionConfig, sectionIndex, colGroupStats[i], microColGroupNodes[i], chunkConfig, i, (sectionRowMaxHeights[sectionIndex] || [])[i] || [], isHeader); })));
|
|
604
|
-
};
|
|
605
|
-
ScrollGrid.prototype.renderChunk = function (sectionConfig, sectionIndex, colGroupStat, microColGroupNode, chunkConfig, chunkIndex, rowHeights, isHeader) {
|
|
606
|
-
if ('outerContent' in chunkConfig) {
|
|
607
|
-
return (common.createElement(common.Fragment, { key: chunkConfig.key }, chunkConfig.outerContent));
|
|
608
|
-
}
|
|
609
|
-
var state = this.state;
|
|
610
|
-
var scrollerClientWidths = state.scrollerClientWidths, scrollerClientHeights = state.scrollerClientHeights;
|
|
611
|
-
var _a = this.getDims(), sectionCnt = _a[0], chunksPerSection = _a[1];
|
|
612
|
-
var index = sectionIndex * chunksPerSection + chunkIndex;
|
|
613
|
-
var sideScrollIndex = (!this.context.isRtl || common.getIsRtlScrollbarOnLeft()) ? chunksPerSection - 1 : 0;
|
|
614
|
-
var isVScrollSide = chunkIndex === sideScrollIndex;
|
|
615
|
-
var isLastSection = sectionIndex === sectionCnt - 1;
|
|
616
|
-
var forceXScrollbars = isLastSection && state.forceXScrollbars; // NOOOO can result in `null`
|
|
617
|
-
var forceYScrollbars = isVScrollSide && state.forceYScrollbars; // NOOOO can result in `null`
|
|
618
|
-
var allowXScrolling = colGroupStat && colGroupStat.allowXScrolling; // rename?
|
|
619
|
-
var allowYScrolling = common.getAllowYScrolling(this.props, sectionConfig); // rename? do in section func?
|
|
620
|
-
var chunkVGrow = common.getSectionHasLiquidHeight(this.props, sectionConfig); // do in section func?
|
|
621
|
-
var expandRows = sectionConfig.expandRows && chunkVGrow;
|
|
622
|
-
var tableMinWidth = (colGroupStat && colGroupStat.totalColMinWidth) || '';
|
|
623
|
-
var content = common.renderChunkContent(sectionConfig, chunkConfig, {
|
|
624
|
-
tableColGroupNode: microColGroupNode,
|
|
625
|
-
tableMinWidth: tableMinWidth,
|
|
626
|
-
clientWidth: scrollerClientWidths[index] !== undefined ? scrollerClientWidths[index] : null,
|
|
627
|
-
clientHeight: scrollerClientHeights[index] !== undefined ? scrollerClientHeights[index] : null,
|
|
628
|
-
expandRows: expandRows,
|
|
629
|
-
syncRowHeights: Boolean(sectionConfig.syncRowHeights),
|
|
630
|
-
rowSyncHeights: rowHeights,
|
|
631
|
-
reportRowHeightChange: this.handleRowHeightChange,
|
|
632
|
-
}, isHeader);
|
|
633
|
-
var overflowX = forceXScrollbars ? (isLastSection ? 'scroll' : 'scroll-hidden') :
|
|
634
|
-
!allowXScrolling ? 'hidden' :
|
|
635
|
-
(isLastSection ? 'auto' : 'scroll-hidden');
|
|
636
|
-
var overflowY = forceYScrollbars ? (isVScrollSide ? 'scroll' : 'scroll-hidden') :
|
|
637
|
-
!allowYScrolling ? 'hidden' :
|
|
638
|
-
(isVScrollSide ? 'auto' : 'scroll-hidden');
|
|
639
|
-
// it *could* be possible to reduce DOM wrappers by only doing a ClippedScroller when allowXScrolling or allowYScrolling,
|
|
640
|
-
// but if these values were to change, the inner components would be unmounted/remounted because of the parent change.
|
|
641
|
-
content = (common.createElement(ClippedScroller, { ref: this.clippedScrollerRefs.createRef(index), scrollerElRef: this.scrollerElRefs.createRef(index), overflowX: overflowX, overflowY: overflowY, liquid: chunkVGrow, maxHeight: sectionConfig.maxHeight }, content));
|
|
642
|
-
return common.createElement(isHeader ? 'th' : 'td', {
|
|
643
|
-
key: chunkConfig.key,
|
|
644
|
-
ref: this.chunkElRefs.createRef(index),
|
|
645
|
-
role: 'presentation',
|
|
646
|
-
}, content);
|
|
647
|
-
};
|
|
648
|
-
ScrollGrid.prototype.componentDidMount = function () {
|
|
649
|
-
this.getStickyScrolling = common.memoizeArraylike(initStickyScrolling, null, destroyStickyScrolling);
|
|
650
|
-
this.getScrollSyncersBySection = common.memoizeHashlike(initScrollSyncer.bind(this, true), null, destroyScrollSyncer);
|
|
651
|
-
this.getScrollSyncersByColumn = common.memoizeHashlike(initScrollSyncer.bind(this, false), null, destroyScrollSyncer);
|
|
652
|
-
this.updateScrollSyncers();
|
|
653
|
-
this.handleSizing(false);
|
|
654
|
-
this.context.addResizeHandler(this.handleSizing);
|
|
655
|
-
};
|
|
656
|
-
ScrollGrid.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
657
|
-
this.updateScrollSyncers();
|
|
658
|
-
// TODO: need better solution when state contains non-sizing things
|
|
659
|
-
this.handleSizing(false, prevState.sectionRowMaxHeights !== this.state.sectionRowMaxHeights);
|
|
660
|
-
};
|
|
661
|
-
ScrollGrid.prototype.componentWillUnmount = function () {
|
|
662
|
-
this.context.removeResizeHandler(this.handleSizing);
|
|
663
|
-
this.destroyStickyScrolling();
|
|
664
|
-
this.destroyScrollSyncers();
|
|
665
|
-
};
|
|
666
|
-
ScrollGrid.prototype.allowSizing = function () {
|
|
667
|
-
var now = new Date();
|
|
668
|
-
if (!this.lastSizingDate ||
|
|
669
|
-
now.valueOf() > this.lastSizingDate.valueOf() + common.config.SCROLLGRID_RESIZE_INTERVAL) {
|
|
670
|
-
this.lastSizingDate = now;
|
|
671
|
-
this.recentSizingCnt = 0;
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
return (this.recentSizingCnt += 1) <= 10;
|
|
675
|
-
};
|
|
676
|
-
ScrollGrid.prototype.computeShrinkWidths = function () {
|
|
677
|
-
var _this = this;
|
|
678
|
-
var colGroupStats = this.compileColGroupStats(this.props.colGroups.map(function (colGroup) { return [colGroup]; }));
|
|
679
|
-
var _a = this.getDims(), sectionCnt = _a[0], chunksPerSection = _a[1];
|
|
680
|
-
var cnt = sectionCnt * chunksPerSection;
|
|
681
|
-
var shrinkWidths = [];
|
|
682
|
-
colGroupStats.forEach(function (colGroupStat, i) {
|
|
683
|
-
if (colGroupStat.hasShrinkCol) {
|
|
684
|
-
var chunkEls = _this.chunkElRefs.collect(i, cnt, chunksPerSection); // in one col
|
|
685
|
-
shrinkWidths[i] = common.computeShrinkWidth(chunkEls);
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
return shrinkWidths;
|
|
689
|
-
};
|
|
690
|
-
// has the side effect of grooming rowInnerMaxHeightMap
|
|
691
|
-
// TODO: somehow short-circuit if there are no new height changes
|
|
692
|
-
ScrollGrid.prototype.computeSectionRowMaxHeights = function () {
|
|
693
|
-
var newHeightMap = new Map();
|
|
694
|
-
var _a = this.getDims(), sectionCnt = _a[0], chunksPerSection = _a[1];
|
|
695
|
-
var sectionRowMaxHeights = [];
|
|
696
|
-
for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) {
|
|
697
|
-
var sectionConfig = this.props.sections[sectionI];
|
|
698
|
-
var assignableHeights = []; // chunk, row
|
|
699
|
-
if (sectionConfig && sectionConfig.syncRowHeights) {
|
|
700
|
-
var rowHeightsByChunk = [];
|
|
701
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) {
|
|
702
|
-
var index = sectionI * chunksPerSection + chunkI;
|
|
703
|
-
var rowHeights = [];
|
|
704
|
-
var chunkEl = this.chunkElRefs.currentMap[index];
|
|
705
|
-
if (chunkEl) {
|
|
706
|
-
rowHeights = common.findElements(chunkEl, '.fc-scrollgrid-sync-table tr').map(function (rowEl) {
|
|
707
|
-
var max = getRowInnerMaxHeight(rowEl);
|
|
708
|
-
newHeightMap.set(rowEl, max);
|
|
709
|
-
return max;
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
else {
|
|
713
|
-
rowHeights = [];
|
|
714
|
-
}
|
|
715
|
-
rowHeightsByChunk.push(rowHeights);
|
|
716
|
-
}
|
|
717
|
-
var rowCnt = rowHeightsByChunk[0].length;
|
|
718
|
-
var isEqualRowCnt = true;
|
|
719
|
-
for (var chunkI = 1; chunkI < chunksPerSection; chunkI += 1) {
|
|
720
|
-
var isOuterContent = sectionConfig.chunks[chunkI] && sectionConfig.chunks[chunkI].outerContent !== undefined; // can be null
|
|
721
|
-
if (!isOuterContent && rowHeightsByChunk[chunkI].length !== rowCnt) { // skip outer content
|
|
722
|
-
isEqualRowCnt = false;
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
if (!isEqualRowCnt) {
|
|
727
|
-
var chunkHeightSums = [];
|
|
728
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) {
|
|
729
|
-
chunkHeightSums.push(sumNumbers(rowHeightsByChunk[chunkI]) + rowHeightsByChunk[chunkI].length);
|
|
730
|
-
}
|
|
731
|
-
var maxTotalSum = Math.max.apply(Math, chunkHeightSums);
|
|
732
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) {
|
|
733
|
-
var rowInChunkCnt = rowHeightsByChunk[chunkI].length;
|
|
734
|
-
var rowInChunkTotalHeight = maxTotalSum - rowInChunkCnt; // subtract border
|
|
735
|
-
// height of non-first row. we do this to avoid rounding, because it's unreliable within a table
|
|
736
|
-
var rowInChunkHeightOthers = Math.floor(rowInChunkTotalHeight / rowInChunkCnt);
|
|
737
|
-
// whatever is leftover goes to the first row
|
|
738
|
-
var rowInChunkHeightFirst = rowInChunkTotalHeight - rowInChunkHeightOthers * (rowInChunkCnt - 1);
|
|
739
|
-
var rowInChunkHeights = [];
|
|
740
|
-
var row = 0;
|
|
741
|
-
if (row < rowInChunkCnt) {
|
|
742
|
-
rowInChunkHeights.push(rowInChunkHeightFirst);
|
|
743
|
-
row += 1;
|
|
744
|
-
}
|
|
745
|
-
while (row < rowInChunkCnt) {
|
|
746
|
-
rowInChunkHeights.push(rowInChunkHeightOthers);
|
|
747
|
-
row += 1;
|
|
748
|
-
}
|
|
749
|
-
assignableHeights.push(rowInChunkHeights);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
else {
|
|
753
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) {
|
|
754
|
-
assignableHeights.push([]);
|
|
755
|
-
}
|
|
756
|
-
for (var row = 0; row < rowCnt; row += 1) {
|
|
757
|
-
var rowHeightsAcrossChunks = [];
|
|
758
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) {
|
|
759
|
-
var h = rowHeightsByChunk[chunkI][row];
|
|
760
|
-
if (h != null) { // protect against outerContent
|
|
761
|
-
rowHeightsAcrossChunks.push(h);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
var maxHeight = Math.max.apply(Math, rowHeightsAcrossChunks);
|
|
765
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) {
|
|
766
|
-
assignableHeights[chunkI].push(maxHeight);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
sectionRowMaxHeights.push(assignableHeights);
|
|
772
|
-
}
|
|
773
|
-
this.rowInnerMaxHeightMap = newHeightMap;
|
|
774
|
-
return sectionRowMaxHeights;
|
|
775
|
-
};
|
|
776
|
-
ScrollGrid.prototype.computeScrollerDims = function () {
|
|
777
|
-
var scrollbarWidth = common.getScrollbarWidths();
|
|
778
|
-
var _a = this.getDims(), sectionCnt = _a[0], chunksPerSection = _a[1];
|
|
779
|
-
var sideScrollI = (!this.context.isRtl || common.getIsRtlScrollbarOnLeft()) ? chunksPerSection - 1 : 0;
|
|
780
|
-
var lastSectionI = sectionCnt - 1;
|
|
781
|
-
var currentScrollers = this.clippedScrollerRefs.currentMap;
|
|
782
|
-
var scrollerEls = this.scrollerElRefs.currentMap;
|
|
783
|
-
var forceYScrollbars = false;
|
|
784
|
-
var forceXScrollbars = false;
|
|
785
|
-
var scrollerClientWidths = {};
|
|
786
|
-
var scrollerClientHeights = {};
|
|
787
|
-
for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) { // along edge
|
|
788
|
-
var index = sectionI * chunksPerSection + sideScrollI;
|
|
789
|
-
var scroller = currentScrollers[index];
|
|
790
|
-
if (scroller && scroller.needsYScrolling()) {
|
|
791
|
-
forceYScrollbars = true;
|
|
792
|
-
break;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) { // along last row
|
|
796
|
-
var index = lastSectionI * chunksPerSection + chunkI;
|
|
797
|
-
var scroller = currentScrollers[index];
|
|
798
|
-
if (scroller && scroller.needsXScrolling()) {
|
|
799
|
-
forceXScrollbars = true;
|
|
800
|
-
break;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) {
|
|
804
|
-
for (var chunkI = 0; chunkI < chunksPerSection; chunkI += 1) {
|
|
805
|
-
var index = sectionI * chunksPerSection + chunkI;
|
|
806
|
-
var scrollerEl = scrollerEls[index];
|
|
807
|
-
if (scrollerEl) {
|
|
808
|
-
// TODO: weird way to get this. need harness b/c doesn't include table borders
|
|
809
|
-
var harnessEl = scrollerEl.parentNode;
|
|
810
|
-
scrollerClientWidths[index] = Math.floor(harnessEl.getBoundingClientRect().width - ((chunkI === sideScrollI && forceYScrollbars)
|
|
811
|
-
? scrollbarWidth.y // use global because scroller might not have scrollbars yet but will need them in future
|
|
812
|
-
: 0));
|
|
813
|
-
scrollerClientHeights[index] = Math.floor(harnessEl.getBoundingClientRect().height - ((sectionI === lastSectionI && forceXScrollbars)
|
|
814
|
-
? scrollbarWidth.x // use global because scroller might not have scrollbars yet but will need them in future
|
|
815
|
-
: 0));
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
return { forceYScrollbars: forceYScrollbars, forceXScrollbars: forceXScrollbars, scrollerClientWidths: scrollerClientWidths, scrollerClientHeights: scrollerClientHeights };
|
|
820
|
-
};
|
|
821
|
-
ScrollGrid.prototype.updateStickyScrolling = function () {
|
|
822
|
-
var isRtl = this.context.isRtl;
|
|
823
|
-
var argsByKey = this.scrollerElRefs.getAll().map(function (scrollEl) { return [scrollEl, isRtl]; });
|
|
824
|
-
var stickyScrollings = this.getStickyScrolling(argsByKey);
|
|
825
|
-
stickyScrollings.forEach(function (stickyScrolling) { return stickyScrolling.updateSize(); });
|
|
826
|
-
this.stickyScrollings = stickyScrollings;
|
|
827
|
-
};
|
|
828
|
-
ScrollGrid.prototype.destroyStickyScrolling = function () {
|
|
829
|
-
this.stickyScrollings.forEach(destroyStickyScrolling);
|
|
830
|
-
};
|
|
831
|
-
ScrollGrid.prototype.updateScrollSyncers = function () {
|
|
832
|
-
var _a = this.getDims(), sectionCnt = _a[0], chunksPerSection = _a[1];
|
|
833
|
-
var cnt = sectionCnt * chunksPerSection;
|
|
834
|
-
var scrollElsBySection = {};
|
|
835
|
-
var scrollElsByColumn = {};
|
|
836
|
-
var scrollElMap = this.scrollerElRefs.currentMap;
|
|
837
|
-
for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) {
|
|
838
|
-
var startIndex = sectionI * chunksPerSection;
|
|
839
|
-
var endIndex = startIndex + chunksPerSection;
|
|
840
|
-
scrollElsBySection[sectionI] = common.collectFromHash(scrollElMap, startIndex, endIndex, 1); // use the filtered
|
|
841
|
-
}
|
|
842
|
-
for (var col = 0; col < chunksPerSection; col += 1) {
|
|
843
|
-
scrollElsByColumn[col] = this.scrollerElRefs.collect(col, cnt, chunksPerSection); // DON'T use the filtered
|
|
844
|
-
}
|
|
845
|
-
this.scrollSyncersBySection = this.getScrollSyncersBySection(scrollElsBySection);
|
|
846
|
-
this.scrollSyncersByColumn = this.getScrollSyncersByColumn(scrollElsByColumn);
|
|
847
|
-
};
|
|
848
|
-
ScrollGrid.prototype.destroyScrollSyncers = function () {
|
|
849
|
-
common.mapHash(this.scrollSyncersBySection, destroyScrollSyncer);
|
|
850
|
-
common.mapHash(this.scrollSyncersByColumn, destroyScrollSyncer);
|
|
851
|
-
};
|
|
852
|
-
ScrollGrid.prototype.getChunkConfigByIndex = function (index) {
|
|
853
|
-
var chunksPerSection = this.getDims()[1];
|
|
854
|
-
var sectionI = Math.floor(index / chunksPerSection);
|
|
855
|
-
var chunkI = index % chunksPerSection;
|
|
856
|
-
var sectionConfig = this.props.sections[sectionI];
|
|
857
|
-
return sectionConfig && sectionConfig.chunks[chunkI];
|
|
858
|
-
};
|
|
859
|
-
ScrollGrid.prototype.forceScrollLeft = function (col, scrollLeft) {
|
|
860
|
-
var scrollSyncer = this.scrollSyncersByColumn[col];
|
|
861
|
-
if (scrollSyncer) {
|
|
862
|
-
scrollSyncer.forceScrollLeft(scrollLeft);
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
ScrollGrid.prototype.forceScrollTop = function (sectionI, scrollTop) {
|
|
866
|
-
var scrollSyncer = this.scrollSyncersBySection[sectionI];
|
|
867
|
-
if (scrollSyncer) {
|
|
868
|
-
scrollSyncer.forceScrollTop(scrollTop);
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
ScrollGrid.prototype._handleChunkEl = function (chunkEl, key) {
|
|
872
|
-
var chunkConfig = this.getChunkConfigByIndex(parseInt(key, 10));
|
|
873
|
-
if (chunkConfig) { // null if section disappeared. bad, b/c won't null-set the elRef
|
|
874
|
-
common.setRef(chunkConfig.elRef, chunkEl);
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
ScrollGrid.prototype._handleScrollerEl = function (scrollerEl, key) {
|
|
878
|
-
var chunkConfig = this.getChunkConfigByIndex(parseInt(key, 10));
|
|
879
|
-
if (chunkConfig) { // null if section disappeared. bad, b/c won't null-set the elRef
|
|
880
|
-
common.setRef(chunkConfig.scrollerElRef, scrollerEl);
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
ScrollGrid.prototype.getDims = function () {
|
|
884
|
-
var sectionCnt = this.props.sections.length;
|
|
885
|
-
var chunksPerSection = sectionCnt ? this.props.sections[0].chunks.length : 0;
|
|
886
|
-
return [sectionCnt, chunksPerSection];
|
|
887
|
-
};
|
|
888
|
-
return ScrollGrid;
|
|
889
|
-
}(common.BaseComponent));
|
|
890
|
-
ScrollGrid.addStateEquality({
|
|
891
|
-
shrinkWidths: common.isArraysEqual,
|
|
892
|
-
scrollerClientWidths: common.isPropsEqual,
|
|
893
|
-
scrollerClientHeights: common.isPropsEqual,
|
|
894
|
-
});
|
|
895
|
-
function sumNumbers(numbers) {
|
|
896
|
-
var sum = 0;
|
|
897
|
-
for (var _i = 0, numbers_1 = numbers; _i < numbers_1.length; _i++) {
|
|
898
|
-
var n = numbers_1[_i];
|
|
899
|
-
sum += n;
|
|
900
|
-
}
|
|
901
|
-
return sum;
|
|
902
|
-
}
|
|
903
|
-
function getRowInnerMaxHeight(rowEl) {
|
|
904
|
-
var innerHeights = common.findElements(rowEl, '.fc-scrollgrid-sync-inner').map(getElHeight);
|
|
905
|
-
if (innerHeights.length) {
|
|
906
|
-
return Math.max.apply(Math, innerHeights);
|
|
907
|
-
}
|
|
908
|
-
return 0;
|
|
909
|
-
}
|
|
910
|
-
function getElHeight(el) {
|
|
911
|
-
return el.offsetHeight; // better to deal with integers, for rounding, for PureComponent
|
|
912
|
-
}
|
|
913
|
-
function renderMacroColGroup(colGroupStats, shrinkWidths) {
|
|
914
|
-
var children = colGroupStats.map(function (colGroupStat, i) {
|
|
915
|
-
var width = colGroupStat.width;
|
|
916
|
-
if (width === 'shrink') {
|
|
917
|
-
width = colGroupStat.totalColWidth + common.sanitizeShrinkWidth(shrinkWidths[i]) + 1; // +1 for border :(
|
|
918
|
-
}
|
|
919
|
-
return ( // eslint-disable-next-line react/jsx-key
|
|
920
|
-
common.createElement("col", { style: { width: width } }));
|
|
921
|
-
});
|
|
922
|
-
return common.createElement.apply(void 0, tslib.__spreadArray(['colgroup', {}], children));
|
|
923
|
-
}
|
|
924
|
-
function compileColGroupStat(colGroupConfig) {
|
|
925
|
-
var totalColWidth = sumColProp(colGroupConfig.cols, 'width'); // excludes "shrink"
|
|
926
|
-
var totalColMinWidth = sumColProp(colGroupConfig.cols, 'minWidth');
|
|
927
|
-
var hasShrinkCol = common.hasShrinkWidth(colGroupConfig.cols);
|
|
928
|
-
var allowXScrolling = colGroupConfig.width !== 'shrink' && Boolean(totalColWidth || totalColMinWidth || hasShrinkCol);
|
|
929
|
-
return {
|
|
930
|
-
hasShrinkCol: hasShrinkCol,
|
|
931
|
-
totalColWidth: totalColWidth,
|
|
932
|
-
totalColMinWidth: totalColMinWidth,
|
|
933
|
-
allowXScrolling: allowXScrolling,
|
|
934
|
-
cols: colGroupConfig.cols,
|
|
935
|
-
width: colGroupConfig.width,
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
function sumColProp(cols, propName) {
|
|
939
|
-
var total = 0;
|
|
940
|
-
for (var _i = 0, cols_1 = cols; _i < cols_1.length; _i++) {
|
|
941
|
-
var col = cols_1[_i];
|
|
942
|
-
var val = col[propName];
|
|
943
|
-
if (typeof val === 'number') {
|
|
944
|
-
total += val * (col.span || 1);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
return total;
|
|
948
|
-
}
|
|
949
|
-
var COL_GROUP_STAT_EQUALITY = {
|
|
950
|
-
cols: common.isColPropsEqual,
|
|
951
|
-
};
|
|
952
|
-
function isColGroupStatsEqual(stat0, stat1) {
|
|
953
|
-
return common.compareObjs(stat0, stat1, COL_GROUP_STAT_EQUALITY);
|
|
954
|
-
}
|
|
955
|
-
// for memoizers...
|
|
956
|
-
function initScrollSyncer(isVertical) {
|
|
957
|
-
var scrollEls = [];
|
|
958
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
959
|
-
scrollEls[_i - 1] = arguments[_i];
|
|
960
|
-
}
|
|
961
|
-
return new ScrollSyncer(isVertical, scrollEls);
|
|
962
|
-
}
|
|
963
|
-
function destroyScrollSyncer(scrollSyncer) {
|
|
964
|
-
scrollSyncer.destroy();
|
|
965
|
-
}
|
|
966
|
-
function initStickyScrolling(scrollEl, isRtl) {
|
|
967
|
-
return new StickyScrolling(scrollEl, isRtl);
|
|
968
|
-
}
|
|
969
|
-
function destroyStickyScrolling(stickyScrolling) {
|
|
970
|
-
stickyScrolling.destroy();
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
var main = common.createPlugin({
|
|
974
|
-
deps: [
|
|
975
|
-
premiumCommonPlugin__default['default'],
|
|
976
|
-
],
|
|
977
|
-
scrollGridImpl: ScrollGrid,
|
|
978
|
-
});
|
|
979
|
-
common.config.SCROLLGRID_RESIZE_INTERVAL = 500;
|
|
980
|
-
|
|
981
|
-
exports.ScrollGrid = ScrollGrid;
|
|
982
|
-
exports.default = main;
|
|
983
|
-
exports.setScrollFromLeftEdge = setScrollFromLeftEdge;
|