@fullcalendar/scrollgrid 5.11.2 → 6.0.0-beta.1

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