jattac.libs.web.responsive-table 0.2.15 → 0.2.17
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/README.md +17 -40
- package/dist/UI/InfiniteTable.d.ts +27 -24
- package/dist/UI/ResponsiveTable.d.ts +15 -7
- package/dist/index.js +152 -1091
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -183,1151 +183,215 @@ class InfiniteScrollPlugin {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
function _extends() {
|
|
187
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
188
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
189
|
-
var t = arguments[e];
|
|
190
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
191
|
-
}
|
|
192
|
-
return n;
|
|
193
|
-
}, _extends.apply(null, arguments);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function _assertThisInitialized(e) {
|
|
197
|
-
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
198
|
-
return e;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function _setPrototypeOf(t, e) {
|
|
202
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
203
|
-
return t.__proto__ = e, t;
|
|
204
|
-
}, _setPrototypeOf(t, e);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function _inheritsLoose(t, o) {
|
|
208
|
-
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
var safeIsNaN = Number.isNaN ||
|
|
212
|
-
function ponyfill(value) {
|
|
213
|
-
return typeof value === 'number' && value !== value;
|
|
214
|
-
};
|
|
215
|
-
function isEqual(first, second) {
|
|
216
|
-
if (first === second) {
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
if (safeIsNaN(first) && safeIsNaN(second)) {
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
function areInputsEqual(newInputs, lastInputs) {
|
|
225
|
-
if (newInputs.length !== lastInputs.length) {
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
for (var i = 0; i < newInputs.length; i++) {
|
|
229
|
-
if (!isEqual(newInputs[i], lastInputs[i])) {
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function memoizeOne(resultFn, isEqual) {
|
|
237
|
-
if (isEqual === void 0) { isEqual = areInputsEqual; }
|
|
238
|
-
var lastThis;
|
|
239
|
-
var lastArgs = [];
|
|
240
|
-
var lastResult;
|
|
241
|
-
var calledOnce = false;
|
|
242
|
-
function memoized() {
|
|
243
|
-
var newArgs = [];
|
|
244
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
245
|
-
newArgs[_i] = arguments[_i];
|
|
246
|
-
}
|
|
247
|
-
if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
|
|
248
|
-
return lastResult;
|
|
249
|
-
}
|
|
250
|
-
lastResult = resultFn.apply(this, newArgs);
|
|
251
|
-
calledOnce = true;
|
|
252
|
-
lastThis = this;
|
|
253
|
-
lastArgs = newArgs;
|
|
254
|
-
return lastResult;
|
|
255
|
-
}
|
|
256
|
-
return memoized;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// Animation frame based implementation of setTimeout.
|
|
260
|
-
// Inspired by Joe Lambert, https://gist.github.com/joelambert/1002116#file-requesttimeout-js
|
|
261
|
-
var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
|
|
262
|
-
var now = hasNativePerformanceNow ? function () {
|
|
263
|
-
return performance.now();
|
|
264
|
-
} : function () {
|
|
265
|
-
return Date.now();
|
|
266
|
-
};
|
|
267
|
-
function cancelTimeout(timeoutID) {
|
|
268
|
-
cancelAnimationFrame(timeoutID.id);
|
|
269
|
-
}
|
|
270
|
-
function requestTimeout(callback, delay) {
|
|
271
|
-
var start = now();
|
|
272
|
-
|
|
273
|
-
function tick() {
|
|
274
|
-
if (now() - start >= delay) {
|
|
275
|
-
callback.call(null);
|
|
276
|
-
} else {
|
|
277
|
-
timeoutID.id = requestAnimationFrame(tick);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
var timeoutID = {
|
|
282
|
-
id: requestAnimationFrame(tick)
|
|
283
|
-
};
|
|
284
|
-
return timeoutID;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
var size = -1; // This utility copied from "dom-helpers" package.
|
|
288
|
-
|
|
289
|
-
function getScrollbarSize(recalculate) {
|
|
290
|
-
if (recalculate === void 0) {
|
|
291
|
-
recalculate = false;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (size === -1 || recalculate) {
|
|
295
|
-
var div = document.createElement('div');
|
|
296
|
-
var style = div.style;
|
|
297
|
-
style.width = '50px';
|
|
298
|
-
style.height = '50px';
|
|
299
|
-
style.overflow = 'scroll';
|
|
300
|
-
document.body.appendChild(div);
|
|
301
|
-
size = div.offsetWidth - div.clientWidth;
|
|
302
|
-
document.body.removeChild(div);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return size;
|
|
306
|
-
}
|
|
307
|
-
var cachedRTLResult = null; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
|
|
308
|
-
// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
|
|
309
|
-
// Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
|
|
310
|
-
// The safest way to check this is to intentionally set a negative offset,
|
|
311
|
-
// and then verify that the subsequent "scroll" event matches the negative offset.
|
|
312
|
-
// If it does not match, then we can assume a non-standard RTL scroll implementation.
|
|
313
|
-
|
|
314
|
-
function getRTLOffsetType(recalculate) {
|
|
315
|
-
if (recalculate === void 0) {
|
|
316
|
-
recalculate = false;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (cachedRTLResult === null || recalculate) {
|
|
320
|
-
var outerDiv = document.createElement('div');
|
|
321
|
-
var outerStyle = outerDiv.style;
|
|
322
|
-
outerStyle.width = '50px';
|
|
323
|
-
outerStyle.height = '50px';
|
|
324
|
-
outerStyle.overflow = 'scroll';
|
|
325
|
-
outerStyle.direction = 'rtl';
|
|
326
|
-
var innerDiv = document.createElement('div');
|
|
327
|
-
var innerStyle = innerDiv.style;
|
|
328
|
-
innerStyle.width = '100px';
|
|
329
|
-
innerStyle.height = '100px';
|
|
330
|
-
outerDiv.appendChild(innerDiv);
|
|
331
|
-
document.body.appendChild(outerDiv);
|
|
332
|
-
|
|
333
|
-
if (outerDiv.scrollLeft > 0) {
|
|
334
|
-
cachedRTLResult = 'positive-descending';
|
|
335
|
-
} else {
|
|
336
|
-
outerDiv.scrollLeft = 1;
|
|
337
|
-
|
|
338
|
-
if (outerDiv.scrollLeft === 0) {
|
|
339
|
-
cachedRTLResult = 'negative';
|
|
340
|
-
} else {
|
|
341
|
-
cachedRTLResult = 'positive-ascending';
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
document.body.removeChild(outerDiv);
|
|
346
|
-
return cachedRTLResult;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return cachedRTLResult;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
if (process.env.NODE_ENV !== 'production') ;
|
|
353
|
-
|
|
354
|
-
var IS_SCROLLING_DEBOUNCE_INTERVAL$1 = 150;
|
|
355
|
-
|
|
356
|
-
var defaultItemKey$1 = function defaultItemKey(index, data) {
|
|
357
|
-
return index;
|
|
358
|
-
}; // In DEV mode, this Set helps us only log a warning once per component instance.
|
|
359
|
-
// This avoids spamming the console every time a render happens.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
var devWarningsDirection = null;
|
|
363
|
-
var devWarningsTagName$1 = null;
|
|
364
|
-
|
|
365
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
366
|
-
if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
|
|
367
|
-
devWarningsDirection = /*#__PURE__*/new WeakSet();
|
|
368
|
-
devWarningsTagName$1 = /*#__PURE__*/new WeakSet();
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
function createListComponent(_ref) {
|
|
373
|
-
var _class;
|
|
374
|
-
|
|
375
|
-
var getItemOffset = _ref.getItemOffset,
|
|
376
|
-
getEstimatedTotalSize = _ref.getEstimatedTotalSize,
|
|
377
|
-
getItemSize = _ref.getItemSize,
|
|
378
|
-
getOffsetForIndexAndAlignment = _ref.getOffsetForIndexAndAlignment,
|
|
379
|
-
getStartIndexForOffset = _ref.getStartIndexForOffset,
|
|
380
|
-
getStopIndexForStartIndex = _ref.getStopIndexForStartIndex,
|
|
381
|
-
initInstanceProps = _ref.initInstanceProps,
|
|
382
|
-
shouldResetStyleCacheOnItemSizeChange = _ref.shouldResetStyleCacheOnItemSizeChange,
|
|
383
|
-
validateProps = _ref.validateProps;
|
|
384
|
-
return _class = /*#__PURE__*/function (_PureComponent) {
|
|
385
|
-
_inheritsLoose(List, _PureComponent);
|
|
386
|
-
|
|
387
|
-
// Always use explicit constructor for React components.
|
|
388
|
-
// It produces less code after transpilation. (#26)
|
|
389
|
-
// eslint-disable-next-line no-useless-constructor
|
|
390
|
-
function List(props) {
|
|
391
|
-
var _this;
|
|
392
|
-
|
|
393
|
-
_this = _PureComponent.call(this, props) || this;
|
|
394
|
-
_this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
|
|
395
|
-
_this._outerRef = void 0;
|
|
396
|
-
_this._resetIsScrollingTimeoutId = null;
|
|
397
|
-
_this.state = {
|
|
398
|
-
instance: _assertThisInitialized(_this),
|
|
399
|
-
isScrolling: false,
|
|
400
|
-
scrollDirection: 'forward',
|
|
401
|
-
scrollOffset: typeof _this.props.initialScrollOffset === 'number' ? _this.props.initialScrollOffset : 0,
|
|
402
|
-
scrollUpdateWasRequested: false
|
|
403
|
-
};
|
|
404
|
-
_this._callOnItemsRendered = void 0;
|
|
405
|
-
_this._callOnItemsRendered = memoizeOne(function (overscanStartIndex, overscanStopIndex, visibleStartIndex, visibleStopIndex) {
|
|
406
|
-
return _this.props.onItemsRendered({
|
|
407
|
-
overscanStartIndex: overscanStartIndex,
|
|
408
|
-
overscanStopIndex: overscanStopIndex,
|
|
409
|
-
visibleStartIndex: visibleStartIndex,
|
|
410
|
-
visibleStopIndex: visibleStopIndex
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
_this._callOnScroll = void 0;
|
|
414
|
-
_this._callOnScroll = memoizeOne(function (scrollDirection, scrollOffset, scrollUpdateWasRequested) {
|
|
415
|
-
return _this.props.onScroll({
|
|
416
|
-
scrollDirection: scrollDirection,
|
|
417
|
-
scrollOffset: scrollOffset,
|
|
418
|
-
scrollUpdateWasRequested: scrollUpdateWasRequested
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
_this._getItemStyle = void 0;
|
|
422
|
-
|
|
423
|
-
_this._getItemStyle = function (index) {
|
|
424
|
-
var _this$props = _this.props,
|
|
425
|
-
direction = _this$props.direction,
|
|
426
|
-
itemSize = _this$props.itemSize,
|
|
427
|
-
layout = _this$props.layout;
|
|
428
|
-
|
|
429
|
-
var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize, shouldResetStyleCacheOnItemSizeChange && layout, shouldResetStyleCacheOnItemSizeChange && direction);
|
|
430
|
-
|
|
431
|
-
var style;
|
|
432
|
-
|
|
433
|
-
if (itemStyleCache.hasOwnProperty(index)) {
|
|
434
|
-
style = itemStyleCache[index];
|
|
435
|
-
} else {
|
|
436
|
-
var _offset = getItemOffset(_this.props, index, _this._instanceProps);
|
|
437
|
-
|
|
438
|
-
var size = getItemSize(_this.props, index, _this._instanceProps); // TODO Deprecate direction "horizontal"
|
|
439
|
-
|
|
440
|
-
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
441
|
-
var isRtl = direction === 'rtl';
|
|
442
|
-
var offsetHorizontal = isHorizontal ? _offset : 0;
|
|
443
|
-
itemStyleCache[index] = style = {
|
|
444
|
-
position: 'absolute',
|
|
445
|
-
left: isRtl ? undefined : offsetHorizontal,
|
|
446
|
-
right: isRtl ? offsetHorizontal : undefined,
|
|
447
|
-
top: !isHorizontal ? _offset : 0,
|
|
448
|
-
height: !isHorizontal ? size : '100%',
|
|
449
|
-
width: isHorizontal ? size : '100%'
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
return style;
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
_this._getItemStyleCache = void 0;
|
|
457
|
-
_this._getItemStyleCache = memoizeOne(function (_, __, ___) {
|
|
458
|
-
return {};
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
_this._onScrollHorizontal = function (event) {
|
|
462
|
-
var _event$currentTarget = event.currentTarget,
|
|
463
|
-
clientWidth = _event$currentTarget.clientWidth,
|
|
464
|
-
scrollLeft = _event$currentTarget.scrollLeft,
|
|
465
|
-
scrollWidth = _event$currentTarget.scrollWidth;
|
|
466
|
-
|
|
467
|
-
_this.setState(function (prevState) {
|
|
468
|
-
if (prevState.scrollOffset === scrollLeft) {
|
|
469
|
-
// Scroll position may have been updated by cDM/cDU,
|
|
470
|
-
// In which case we don't need to trigger another render,
|
|
471
|
-
// And we don't want to update state.isScrolling.
|
|
472
|
-
return null;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
var direction = _this.props.direction;
|
|
476
|
-
var scrollOffset = scrollLeft;
|
|
477
|
-
|
|
478
|
-
if (direction === 'rtl') {
|
|
479
|
-
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
|
|
480
|
-
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
|
|
481
|
-
// It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
|
|
482
|
-
// So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
|
|
483
|
-
switch (getRTLOffsetType()) {
|
|
484
|
-
case 'negative':
|
|
485
|
-
scrollOffset = -scrollLeft;
|
|
486
|
-
break;
|
|
487
|
-
|
|
488
|
-
case 'positive-descending':
|
|
489
|
-
scrollOffset = scrollWidth - clientWidth - scrollLeft;
|
|
490
|
-
break;
|
|
491
|
-
}
|
|
492
|
-
} // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
scrollOffset = Math.max(0, Math.min(scrollOffset, scrollWidth - clientWidth));
|
|
496
|
-
return {
|
|
497
|
-
isScrolling: true,
|
|
498
|
-
scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
|
|
499
|
-
scrollOffset: scrollOffset,
|
|
500
|
-
scrollUpdateWasRequested: false
|
|
501
|
-
};
|
|
502
|
-
}, _this._resetIsScrollingDebounced);
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
_this._onScrollVertical = function (event) {
|
|
506
|
-
var _event$currentTarget2 = event.currentTarget,
|
|
507
|
-
clientHeight = _event$currentTarget2.clientHeight,
|
|
508
|
-
scrollHeight = _event$currentTarget2.scrollHeight,
|
|
509
|
-
scrollTop = _event$currentTarget2.scrollTop;
|
|
510
|
-
|
|
511
|
-
_this.setState(function (prevState) {
|
|
512
|
-
if (prevState.scrollOffset === scrollTop) {
|
|
513
|
-
// Scroll position may have been updated by cDM/cDU,
|
|
514
|
-
// In which case we don't need to trigger another render,
|
|
515
|
-
// And we don't want to update state.isScrolling.
|
|
516
|
-
return null;
|
|
517
|
-
} // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
var scrollOffset = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
|
|
521
|
-
return {
|
|
522
|
-
isScrolling: true,
|
|
523
|
-
scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
|
|
524
|
-
scrollOffset: scrollOffset,
|
|
525
|
-
scrollUpdateWasRequested: false
|
|
526
|
-
};
|
|
527
|
-
}, _this._resetIsScrollingDebounced);
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
_this._outerRefSetter = function (ref) {
|
|
531
|
-
var outerRef = _this.props.outerRef;
|
|
532
|
-
_this._outerRef = ref;
|
|
533
|
-
|
|
534
|
-
if (typeof outerRef === 'function') {
|
|
535
|
-
outerRef(ref);
|
|
536
|
-
} else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
|
|
537
|
-
outerRef.current = ref;
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
_this._resetIsScrollingDebounced = function () {
|
|
542
|
-
if (_this._resetIsScrollingTimeoutId !== null) {
|
|
543
|
-
cancelTimeout(_this._resetIsScrollingTimeoutId);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
_this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL$1);
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
_this._resetIsScrolling = function () {
|
|
550
|
-
_this._resetIsScrollingTimeoutId = null;
|
|
551
|
-
|
|
552
|
-
_this.setState({
|
|
553
|
-
isScrolling: false
|
|
554
|
-
}, function () {
|
|
555
|
-
// Clear style cache after state update has been committed.
|
|
556
|
-
// This way we don't break pure sCU for items that don't use isScrolling param.
|
|
557
|
-
_this._getItemStyleCache(-1, null);
|
|
558
|
-
});
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
return _this;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
List.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
|
|
565
|
-
validateSharedProps$1(nextProps, prevState);
|
|
566
|
-
validateProps(nextProps);
|
|
567
|
-
return null;
|
|
568
|
-
};
|
|
569
|
-
|
|
570
|
-
var _proto = List.prototype;
|
|
571
|
-
|
|
572
|
-
_proto.scrollTo = function scrollTo(scrollOffset) {
|
|
573
|
-
scrollOffset = Math.max(0, scrollOffset);
|
|
574
|
-
this.setState(function (prevState) {
|
|
575
|
-
if (prevState.scrollOffset === scrollOffset) {
|
|
576
|
-
return null;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
return {
|
|
580
|
-
scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
|
|
581
|
-
scrollOffset: scrollOffset,
|
|
582
|
-
scrollUpdateWasRequested: true
|
|
583
|
-
};
|
|
584
|
-
}, this._resetIsScrollingDebounced);
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
_proto.scrollToItem = function scrollToItem(index, align) {
|
|
588
|
-
if (align === void 0) {
|
|
589
|
-
align = 'auto';
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
var _this$props2 = this.props,
|
|
593
|
-
itemCount = _this$props2.itemCount,
|
|
594
|
-
layout = _this$props2.layout;
|
|
595
|
-
var scrollOffset = this.state.scrollOffset;
|
|
596
|
-
index = Math.max(0, Math.min(index, itemCount - 1)); // The scrollbar size should be considered when scrolling an item into view, to ensure it's fully visible.
|
|
597
|
-
// But we only need to account for its size when it's actually visible.
|
|
598
|
-
// This is an edge case for lists; normally they only scroll in the dominant direction.
|
|
599
|
-
|
|
600
|
-
var scrollbarSize = 0;
|
|
601
|
-
|
|
602
|
-
if (this._outerRef) {
|
|
603
|
-
var outerRef = this._outerRef;
|
|
604
|
-
|
|
605
|
-
if (layout === 'vertical') {
|
|
606
|
-
scrollbarSize = outerRef.scrollWidth > outerRef.clientWidth ? getScrollbarSize() : 0;
|
|
607
|
-
} else {
|
|
608
|
-
scrollbarSize = outerRef.scrollHeight > outerRef.clientHeight ? getScrollbarSize() : 0;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps, scrollbarSize));
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
616
|
-
var _this$props3 = this.props,
|
|
617
|
-
direction = _this$props3.direction,
|
|
618
|
-
initialScrollOffset = _this$props3.initialScrollOffset,
|
|
619
|
-
layout = _this$props3.layout;
|
|
620
|
-
|
|
621
|
-
if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
|
|
622
|
-
var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
|
|
623
|
-
|
|
624
|
-
if (direction === 'horizontal' || layout === 'horizontal') {
|
|
625
|
-
outerRef.scrollLeft = initialScrollOffset;
|
|
626
|
-
} else {
|
|
627
|
-
outerRef.scrollTop = initialScrollOffset;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
this._callPropsCallbacks();
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
635
|
-
var _this$props4 = this.props,
|
|
636
|
-
direction = _this$props4.direction,
|
|
637
|
-
layout = _this$props4.layout;
|
|
638
|
-
var _this$state = this.state,
|
|
639
|
-
scrollOffset = _this$state.scrollOffset,
|
|
640
|
-
scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
|
|
641
|
-
|
|
642
|
-
if (scrollUpdateWasRequested && this._outerRef != null) {
|
|
643
|
-
var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
|
|
644
|
-
|
|
645
|
-
if (direction === 'horizontal' || layout === 'horizontal') {
|
|
646
|
-
if (direction === 'rtl') {
|
|
647
|
-
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
|
|
648
|
-
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
|
|
649
|
-
// So we need to determine which browser behavior we're dealing with, and mimic it.
|
|
650
|
-
switch (getRTLOffsetType()) {
|
|
651
|
-
case 'negative':
|
|
652
|
-
outerRef.scrollLeft = -scrollOffset;
|
|
653
|
-
break;
|
|
654
|
-
|
|
655
|
-
case 'positive-ascending':
|
|
656
|
-
outerRef.scrollLeft = scrollOffset;
|
|
657
|
-
break;
|
|
658
|
-
|
|
659
|
-
default:
|
|
660
|
-
var clientWidth = outerRef.clientWidth,
|
|
661
|
-
scrollWidth = outerRef.scrollWidth;
|
|
662
|
-
outerRef.scrollLeft = scrollWidth - clientWidth - scrollOffset;
|
|
663
|
-
break;
|
|
664
|
-
}
|
|
665
|
-
} else {
|
|
666
|
-
outerRef.scrollLeft = scrollOffset;
|
|
667
|
-
}
|
|
668
|
-
} else {
|
|
669
|
-
outerRef.scrollTop = scrollOffset;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
this._callPropsCallbacks();
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
677
|
-
if (this._resetIsScrollingTimeoutId !== null) {
|
|
678
|
-
cancelTimeout(this._resetIsScrollingTimeoutId);
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
_proto.render = function render() {
|
|
683
|
-
var _this$props5 = this.props,
|
|
684
|
-
children = _this$props5.children,
|
|
685
|
-
className = _this$props5.className,
|
|
686
|
-
direction = _this$props5.direction,
|
|
687
|
-
height = _this$props5.height,
|
|
688
|
-
innerRef = _this$props5.innerRef,
|
|
689
|
-
innerElementType = _this$props5.innerElementType,
|
|
690
|
-
innerTagName = _this$props5.innerTagName,
|
|
691
|
-
itemCount = _this$props5.itemCount,
|
|
692
|
-
itemData = _this$props5.itemData,
|
|
693
|
-
_this$props5$itemKey = _this$props5.itemKey,
|
|
694
|
-
itemKey = _this$props5$itemKey === void 0 ? defaultItemKey$1 : _this$props5$itemKey,
|
|
695
|
-
layout = _this$props5.layout,
|
|
696
|
-
outerElementType = _this$props5.outerElementType,
|
|
697
|
-
outerTagName = _this$props5.outerTagName,
|
|
698
|
-
style = _this$props5.style,
|
|
699
|
-
useIsScrolling = _this$props5.useIsScrolling,
|
|
700
|
-
width = _this$props5.width;
|
|
701
|
-
var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
|
|
702
|
-
|
|
703
|
-
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
704
|
-
var onScroll = isHorizontal ? this._onScrollHorizontal : this._onScrollVertical;
|
|
705
|
-
|
|
706
|
-
var _this$_getRangeToRend = this._getRangeToRender(),
|
|
707
|
-
startIndex = _this$_getRangeToRend[0],
|
|
708
|
-
stopIndex = _this$_getRangeToRend[1];
|
|
709
|
-
|
|
710
|
-
var items = [];
|
|
711
|
-
|
|
712
|
-
if (itemCount > 0) {
|
|
713
|
-
for (var _index = startIndex; _index <= stopIndex; _index++) {
|
|
714
|
-
items.push(React.createElement(children, {
|
|
715
|
-
data: itemData,
|
|
716
|
-
key: itemKey(_index, itemData),
|
|
717
|
-
index: _index,
|
|
718
|
-
isScrolling: useIsScrolling ? isScrolling : undefined,
|
|
719
|
-
style: this._getItemStyle(_index)
|
|
720
|
-
}));
|
|
721
|
-
}
|
|
722
|
-
} // Read this value AFTER items have been created,
|
|
723
|
-
// So their actual sizes (if variable) are taken into consideration.
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
var estimatedTotalSize = getEstimatedTotalSize(this.props, this._instanceProps);
|
|
727
|
-
return React.createElement(outerElementType || outerTagName || 'div', {
|
|
728
|
-
className: className,
|
|
729
|
-
onScroll: onScroll,
|
|
730
|
-
ref: this._outerRefSetter,
|
|
731
|
-
style: _extends({
|
|
732
|
-
position: 'relative',
|
|
733
|
-
height: height,
|
|
734
|
-
width: width,
|
|
735
|
-
overflow: 'auto',
|
|
736
|
-
WebkitOverflowScrolling: 'touch',
|
|
737
|
-
willChange: 'transform',
|
|
738
|
-
direction: direction
|
|
739
|
-
}, style)
|
|
740
|
-
}, React.createElement(innerElementType || innerTagName || 'div', {
|
|
741
|
-
children: items,
|
|
742
|
-
ref: innerRef,
|
|
743
|
-
style: {
|
|
744
|
-
height: isHorizontal ? '100%' : estimatedTotalSize,
|
|
745
|
-
pointerEvents: isScrolling ? 'none' : undefined,
|
|
746
|
-
width: isHorizontal ? estimatedTotalSize : '100%'
|
|
747
|
-
}
|
|
748
|
-
}));
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
_proto._callPropsCallbacks = function _callPropsCallbacks() {
|
|
752
|
-
if (typeof this.props.onItemsRendered === 'function') {
|
|
753
|
-
var itemCount = this.props.itemCount;
|
|
754
|
-
|
|
755
|
-
if (itemCount > 0) {
|
|
756
|
-
var _this$_getRangeToRend2 = this._getRangeToRender(),
|
|
757
|
-
_overscanStartIndex = _this$_getRangeToRend2[0],
|
|
758
|
-
_overscanStopIndex = _this$_getRangeToRend2[1],
|
|
759
|
-
_visibleStartIndex = _this$_getRangeToRend2[2],
|
|
760
|
-
_visibleStopIndex = _this$_getRangeToRend2[3];
|
|
761
|
-
|
|
762
|
-
this._callOnItemsRendered(_overscanStartIndex, _overscanStopIndex, _visibleStartIndex, _visibleStopIndex);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
if (typeof this.props.onScroll === 'function') {
|
|
767
|
-
var _this$state2 = this.state,
|
|
768
|
-
_scrollDirection = _this$state2.scrollDirection,
|
|
769
|
-
_scrollOffset = _this$state2.scrollOffset,
|
|
770
|
-
_scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
|
|
771
|
-
|
|
772
|
-
this._callOnScroll(_scrollDirection, _scrollOffset, _scrollUpdateWasRequested);
|
|
773
|
-
}
|
|
774
|
-
} // Lazily create and cache item styles while scrolling,
|
|
775
|
-
// So that pure component sCU will prevent re-renders.
|
|
776
|
-
// We maintain this cache, and pass a style prop rather than index,
|
|
777
|
-
// So that List can clear cached styles and force item re-render if necessary.
|
|
778
|
-
;
|
|
779
|
-
|
|
780
|
-
_proto._getRangeToRender = function _getRangeToRender() {
|
|
781
|
-
var _this$props6 = this.props,
|
|
782
|
-
itemCount = _this$props6.itemCount,
|
|
783
|
-
overscanCount = _this$props6.overscanCount;
|
|
784
|
-
var _this$state3 = this.state,
|
|
785
|
-
isScrolling = _this$state3.isScrolling,
|
|
786
|
-
scrollDirection = _this$state3.scrollDirection,
|
|
787
|
-
scrollOffset = _this$state3.scrollOffset;
|
|
788
|
-
|
|
789
|
-
if (itemCount === 0) {
|
|
790
|
-
return [0, 0, 0, 0];
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
var startIndex = getStartIndexForOffset(this.props, scrollOffset, this._instanceProps);
|
|
794
|
-
var stopIndex = getStopIndexForStartIndex(this.props, startIndex, scrollOffset, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
|
|
795
|
-
// If there isn't at least one extra item, tab loops back around.
|
|
796
|
-
|
|
797
|
-
var overscanBackward = !isScrolling || scrollDirection === 'backward' ? Math.max(1, overscanCount) : 1;
|
|
798
|
-
var overscanForward = !isScrolling || scrollDirection === 'forward' ? Math.max(1, overscanCount) : 1;
|
|
799
|
-
return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(itemCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
return List;
|
|
803
|
-
}(React.PureComponent), _class.defaultProps = {
|
|
804
|
-
direction: 'ltr',
|
|
805
|
-
itemData: undefined,
|
|
806
|
-
layout: 'vertical',
|
|
807
|
-
overscanCount: 2,
|
|
808
|
-
useIsScrolling: false
|
|
809
|
-
}, _class;
|
|
810
|
-
} // NOTE: I considered further wrapping individual items with a pure ListItem component.
|
|
811
|
-
// This would avoid ever calling the render function for the same index more than once,
|
|
812
|
-
// But it would also add the overhead of a lot of components/fibers.
|
|
813
|
-
// I assume people already do this (render function returning a class component),
|
|
814
|
-
// So my doing it would just unnecessarily double the wrappers.
|
|
815
|
-
|
|
816
|
-
var validateSharedProps$1 = function validateSharedProps(_ref2, _ref3) {
|
|
817
|
-
var children = _ref2.children,
|
|
818
|
-
direction = _ref2.direction,
|
|
819
|
-
height = _ref2.height,
|
|
820
|
-
layout = _ref2.layout,
|
|
821
|
-
innerTagName = _ref2.innerTagName,
|
|
822
|
-
outerTagName = _ref2.outerTagName,
|
|
823
|
-
width = _ref2.width;
|
|
824
|
-
var instance = _ref3.instance;
|
|
825
|
-
|
|
826
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
827
|
-
if (innerTagName != null || outerTagName != null) {
|
|
828
|
-
if (devWarningsTagName$1 && !devWarningsTagName$1.has(instance)) {
|
|
829
|
-
devWarningsTagName$1.add(instance);
|
|
830
|
-
console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
|
|
831
|
-
}
|
|
832
|
-
} // TODO Deprecate direction "horizontal"
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
836
|
-
|
|
837
|
-
switch (direction) {
|
|
838
|
-
case 'horizontal':
|
|
839
|
-
case 'vertical':
|
|
840
|
-
if (devWarningsDirection && !devWarningsDirection.has(instance)) {
|
|
841
|
-
devWarningsDirection.add(instance);
|
|
842
|
-
console.warn('The direction prop should be either "ltr" (default) or "rtl". ' + 'Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.');
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
break;
|
|
846
|
-
|
|
847
|
-
case 'ltr':
|
|
848
|
-
case 'rtl':
|
|
849
|
-
// Valid values
|
|
850
|
-
break;
|
|
851
|
-
|
|
852
|
-
default:
|
|
853
|
-
throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
switch (layout) {
|
|
857
|
-
case 'horizontal':
|
|
858
|
-
case 'vertical':
|
|
859
|
-
// Valid values
|
|
860
|
-
break;
|
|
861
|
-
|
|
862
|
-
default:
|
|
863
|
-
throw Error('An invalid "layout" prop has been specified. ' + 'Value should be either "horizontal" or "vertical". ' + ("\"" + layout + "\" was specified."));
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
if (children == null) {
|
|
867
|
-
throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
if (isHorizontal && typeof width !== 'number') {
|
|
871
|
-
throw Error('An invalid "width" prop has been specified. ' + 'Horizontal lists must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
|
|
872
|
-
} else if (!isHorizontal && typeof height !== 'number') {
|
|
873
|
-
throw Error('An invalid "height" prop has been specified. ' + 'Vertical lists must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
var FixedSizeList = /*#__PURE__*/createListComponent({
|
|
879
|
-
getItemOffset: function getItemOffset(_ref, index) {
|
|
880
|
-
var itemSize = _ref.itemSize;
|
|
881
|
-
return index * itemSize;
|
|
882
|
-
},
|
|
883
|
-
getItemSize: function getItemSize(_ref2, index) {
|
|
884
|
-
var itemSize = _ref2.itemSize;
|
|
885
|
-
return itemSize;
|
|
886
|
-
},
|
|
887
|
-
getEstimatedTotalSize: function getEstimatedTotalSize(_ref3) {
|
|
888
|
-
var itemCount = _ref3.itemCount,
|
|
889
|
-
itemSize = _ref3.itemSize;
|
|
890
|
-
return itemSize * itemCount;
|
|
891
|
-
},
|
|
892
|
-
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset, instanceProps, scrollbarSize) {
|
|
893
|
-
var direction = _ref4.direction,
|
|
894
|
-
height = _ref4.height,
|
|
895
|
-
itemCount = _ref4.itemCount,
|
|
896
|
-
itemSize = _ref4.itemSize,
|
|
897
|
-
layout = _ref4.layout,
|
|
898
|
-
width = _ref4.width;
|
|
899
|
-
// TODO Deprecate direction "horizontal"
|
|
900
|
-
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
901
|
-
var size = isHorizontal ? width : height;
|
|
902
|
-
var lastItemOffset = Math.max(0, itemCount * itemSize - size);
|
|
903
|
-
var maxOffset = Math.min(lastItemOffset, index * itemSize);
|
|
904
|
-
var minOffset = Math.max(0, index * itemSize - size + itemSize + scrollbarSize);
|
|
905
|
-
|
|
906
|
-
if (align === 'smart') {
|
|
907
|
-
if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
|
|
908
|
-
align = 'auto';
|
|
909
|
-
} else {
|
|
910
|
-
align = 'center';
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
switch (align) {
|
|
915
|
-
case 'start':
|
|
916
|
-
return maxOffset;
|
|
917
|
-
|
|
918
|
-
case 'end':
|
|
919
|
-
return minOffset;
|
|
920
|
-
|
|
921
|
-
case 'center':
|
|
922
|
-
{
|
|
923
|
-
// "Centered" offset is usually the average of the min and max.
|
|
924
|
-
// But near the edges of the list, this doesn't hold true.
|
|
925
|
-
var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
|
|
926
|
-
|
|
927
|
-
if (middleOffset < Math.ceil(size / 2)) {
|
|
928
|
-
return 0; // near the beginning
|
|
929
|
-
} else if (middleOffset > lastItemOffset + Math.floor(size / 2)) {
|
|
930
|
-
return lastItemOffset; // near the end
|
|
931
|
-
} else {
|
|
932
|
-
return middleOffset;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
case 'auto':
|
|
937
|
-
default:
|
|
938
|
-
if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
|
|
939
|
-
return scrollOffset;
|
|
940
|
-
} else if (scrollOffset < minOffset) {
|
|
941
|
-
return minOffset;
|
|
942
|
-
} else {
|
|
943
|
-
return maxOffset;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
},
|
|
948
|
-
getStartIndexForOffset: function getStartIndexForOffset(_ref5, offset) {
|
|
949
|
-
var itemCount = _ref5.itemCount,
|
|
950
|
-
itemSize = _ref5.itemSize;
|
|
951
|
-
return Math.max(0, Math.min(itemCount - 1, Math.floor(offset / itemSize)));
|
|
952
|
-
},
|
|
953
|
-
getStopIndexForStartIndex: function getStopIndexForStartIndex(_ref6, startIndex, scrollOffset) {
|
|
954
|
-
var direction = _ref6.direction,
|
|
955
|
-
height = _ref6.height,
|
|
956
|
-
itemCount = _ref6.itemCount,
|
|
957
|
-
itemSize = _ref6.itemSize,
|
|
958
|
-
layout = _ref6.layout,
|
|
959
|
-
width = _ref6.width;
|
|
960
|
-
// TODO Deprecate direction "horizontal"
|
|
961
|
-
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
962
|
-
var offset = startIndex * itemSize;
|
|
963
|
-
var size = isHorizontal ? width : height;
|
|
964
|
-
var numVisibleItems = Math.ceil((size + scrollOffset - offset) / itemSize);
|
|
965
|
-
return Math.max(0, Math.min(itemCount - 1, startIndex + numVisibleItems - 1 // -1 is because stop index is inclusive
|
|
966
|
-
));
|
|
967
|
-
},
|
|
968
|
-
initInstanceProps: function initInstanceProps(props) {// Noop
|
|
969
|
-
},
|
|
970
|
-
shouldResetStyleCacheOnItemSizeChange: true,
|
|
971
|
-
validateProps: function validateProps(_ref7) {
|
|
972
|
-
var itemSize = _ref7.itemSize;
|
|
973
|
-
|
|
974
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
975
|
-
if (typeof itemSize !== 'number') {
|
|
976
|
-
throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
});
|
|
981
|
-
|
|
982
|
-
// Class component
|
|
983
186
|
class InfiniteTable extends React.Component {
|
|
984
187
|
constructor(props) {
|
|
985
188
|
super(props);
|
|
986
189
|
this.tableContainerRef = React.createRef();
|
|
987
190
|
this.headerRef = React.createRef();
|
|
988
|
-
this.
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
191
|
+
this.throttle = (func, limit) => {
|
|
192
|
+
let inThrottle;
|
|
193
|
+
return (event) => {
|
|
194
|
+
if (!inThrottle) {
|
|
195
|
+
func(event);
|
|
196
|
+
inThrottle = true;
|
|
197
|
+
setTimeout(() => (inThrottle = false), limit);
|
|
995
198
|
}
|
|
996
|
-
}
|
|
199
|
+
};
|
|
997
200
|
};
|
|
998
|
-
this.
|
|
999
|
-
|
|
201
|
+
this.handleResize = () => {
|
|
202
|
+
this.setState({
|
|
203
|
+
isMobile: window.innerWidth <= (this.props.mobileBreakpoint || 600),
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
this.handleScroll = (event) => {
|
|
207
|
+
var _a;
|
|
208
|
+
const { currentTarget } = event;
|
|
209
|
+
const { scrollHeight, scrollTop, clientHeight } = currentTarget;
|
|
210
|
+
const { isLoadingMore } = this.state;
|
|
211
|
+
const hasMore = ((_a = this.props.infiniteScrollProps) === null || _a === void 0 ? void 0 : _a.hasMore) !== undefined
|
|
212
|
+
? this.props.infiniteScrollProps.hasMore
|
|
213
|
+
: this.state.internalHasMore;
|
|
214
|
+
if (this.props.enablePageLevelStickyHeader !== false && this.headerRef.current) {
|
|
1000
215
|
const { top } = this.headerRef.current.getBoundingClientRect();
|
|
1001
216
|
const isSticky = top <= 0;
|
|
1002
217
|
if (isSticky !== this.state.isHeaderSticky) {
|
|
1003
218
|
this.setState({ isHeaderSticky: isSticky });
|
|
1004
219
|
}
|
|
1005
220
|
}
|
|
221
|
+
if (hasMore && !isLoadingMore && scrollHeight - scrollTop - clientHeight < 100) {
|
|
222
|
+
this.loadMoreData();
|
|
223
|
+
}
|
|
1006
224
|
};
|
|
1007
|
-
this.
|
|
1008
|
-
this.
|
|
1009
|
-
|
|
225
|
+
this.loadMoreData = () => {
|
|
226
|
+
const { infiniteScrollProps } = this.props;
|
|
227
|
+
if (!infiniteScrollProps)
|
|
228
|
+
return;
|
|
229
|
+
this.setState({ isLoadingMore: true }, () => __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
const newItems = yield ((_a = infiniteScrollProps === null || infiniteScrollProps === void 0 ? void 0 : infiniteScrollProps.onLoadMore) === null || _a === void 0 ? void 0 : _a.call(infiniteScrollProps, this.state.internalData));
|
|
232
|
+
if (((_b = this.props.infiniteScrollProps) === null || _b === void 0 ? void 0 : _b.hasMore) === undefined) {
|
|
233
|
+
if (!newItems || newItems.length === 0) {
|
|
234
|
+
this.setState({ internalHasMore: false });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (newItems && newItems.length > 0) {
|
|
238
|
+
const newInternalData = [...this.state.internalData, ...newItems];
|
|
239
|
+
this.setState({ internalData: newInternalData }, () => {
|
|
240
|
+
this.processData(); // Re-process data after new items are added
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
this.setState({ isLoadingMore: false });
|
|
244
|
+
}));
|
|
245
|
+
};
|
|
246
|
+
this.processData = () => {
|
|
247
|
+
let processed = [...this.state.internalData];
|
|
248
|
+
this.state.activePlugins.forEach((plugin) => {
|
|
249
|
+
if (plugin.processData) {
|
|
250
|
+
processed = plugin.processData(processed);
|
|
251
|
+
}
|
|
1010
252
|
});
|
|
253
|
+
this.setState({ processedData: processed });
|
|
254
|
+
};
|
|
255
|
+
this.getColumnDefinition = (colDef, rowIndex) => {
|
|
256
|
+
if (typeof colDef === 'function') {
|
|
257
|
+
return colDef(this.data[rowIndex], rowIndex);
|
|
258
|
+
}
|
|
259
|
+
return colDef;
|
|
260
|
+
};
|
|
261
|
+
this.getRawColumnDefinition = (colDef) => {
|
|
262
|
+
if (typeof colDef === 'function') {
|
|
263
|
+
return colDef(this.data[0], 0);
|
|
264
|
+
}
|
|
265
|
+
return colDef;
|
|
266
|
+
};
|
|
267
|
+
this.onHeaderClickCallback = (colDef) => {
|
|
268
|
+
var _a;
|
|
269
|
+
const raw = this.getRawColumnDefinition(colDef);
|
|
270
|
+
return (_a = raw.interactivity) === null || _a === void 0 ? void 0 : _a.onHeaderClick;
|
|
271
|
+
};
|
|
272
|
+
this.getClickableHeaderClassName = (colDef) => {
|
|
273
|
+
var _a;
|
|
274
|
+
const raw = this.getRawColumnDefinition(colDef);
|
|
275
|
+
return ((_a = raw.interactivity) === null || _a === void 0 ? void 0 : _a.onHeaderClick) ? raw.interactivity.className || styles.clickableHeader : '';
|
|
276
|
+
};
|
|
277
|
+
this.getHeaderProps = (colDef) => {
|
|
278
|
+
const headerProps = {};
|
|
279
|
+
this.state.activePlugins.forEach(plugin => {
|
|
280
|
+
if (plugin.getHeaderProps) {
|
|
281
|
+
Object.assign(headerProps, plugin.getHeaderProps(this.getRawColumnDefinition(colDef)));
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
return headerProps;
|
|
1011
285
|
};
|
|
1012
286
|
this.state = {
|
|
1013
287
|
isMobile: false,
|
|
1014
|
-
|
|
288
|
+
internalData: props.data || [],
|
|
289
|
+
processedData: props.data || [],
|
|
1015
290
|
isLoadingMore: false,
|
|
291
|
+
internalHasMore: true,
|
|
1016
292
|
isHeaderSticky: false,
|
|
1017
|
-
|
|
293
|
+
activePlugins: [],
|
|
1018
294
|
};
|
|
1019
295
|
this.debouncedResize = this.debounce(this.handleResize, 200);
|
|
1020
|
-
|
|
1021
|
-
get mobileBreakpoint() {
|
|
1022
|
-
return this.props.mobileBreakpoint || 600;
|
|
1023
|
-
}
|
|
1024
|
-
debounce(func, delay) {
|
|
1025
|
-
let timeout;
|
|
1026
|
-
return () => {
|
|
1027
|
-
clearTimeout(timeout);
|
|
1028
|
-
timeout = setTimeout(() => func(), delay);
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
get data() {
|
|
1032
|
-
if (Array.isArray(this.state.processedData) && this.state.processedData.length > 0) {
|
|
1033
|
-
return this.state.processedData;
|
|
1034
|
-
}
|
|
1035
|
-
else {
|
|
1036
|
-
return [];
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
get noDataSvg() {
|
|
1040
|
-
return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "#ccc", height: "40", width: "40", viewBox: "0 0 24 24" },
|
|
1041
|
-
React.createElement("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-14h2v6h-2zm0 8h2v2h-2z" })));
|
|
1042
|
-
}
|
|
1043
|
-
get hasData() {
|
|
1044
|
-
return this.data.length > 0;
|
|
1045
|
-
}
|
|
1046
|
-
get noDataComponent() {
|
|
1047
|
-
return (this.props.noDataComponent || (React.createElement("div", { className: styles.noDataWrapper },
|
|
1048
|
-
this.noDataSvg,
|
|
1049
|
-
React.createElement("div", { className: styles.noData }, "No data"))));
|
|
296
|
+
this.throttledScrollHandler = this.throttle(this.handleScroll, 200);
|
|
1050
297
|
}
|
|
1051
298
|
componentDidMount() {
|
|
1052
|
-
this.handleResize();
|
|
299
|
+
this.handleResize();
|
|
1053
300
|
window.addEventListener('resize', this.debouncedResize);
|
|
1054
|
-
if (this.props.enablePageLevelStickyHeader !== false) {
|
|
1055
|
-
window.addEventListener('scroll', this.handleScroll);
|
|
1056
|
-
}
|
|
1057
301
|
this.initializePlugins();
|
|
1058
|
-
if (this.
|
|
1059
|
-
this.
|
|
1060
|
-
this.resizeObserver = new ResizeObserver(this.measureHeader);
|
|
1061
|
-
this.resizeObserver.observe(this.headerRef.current);
|
|
302
|
+
if (this.props.data.length === 0) {
|
|
303
|
+
this.loadMoreData();
|
|
1062
304
|
}
|
|
1063
305
|
}
|
|
1064
306
|
componentWillUnmount() {
|
|
1065
307
|
window.removeEventListener('resize', this.debouncedResize);
|
|
1066
|
-
if (this.props.enablePageLevelStickyHeader !== false) {
|
|
1067
|
-
window.removeEventListener('scroll', this.handleScroll);
|
|
1068
|
-
}
|
|
1069
|
-
if (this.resizeObserver && this.headerRef.current) {
|
|
1070
|
-
this.resizeObserver.unobserve(this.headerRef.current);
|
|
1071
|
-
}
|
|
1072
308
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
this.measureHeader();
|
|
1080
|
-
}
|
|
1081
|
-
// Handle infinite scroll loading
|
|
1082
|
-
if (((_a = this.props.infiniteScrollProps) === null || _a === void 0 ? void 0 : _a.enableInfiniteScroll) && ((_b = this.props.infiniteScrollProps) === null || _b === void 0 ? void 0 : _b.hasMore) && !this.state.isLoadingMore && ((_c = this.props.infiniteScrollProps) === null || _c === void 0 ? void 0 : _c.onLoadMore)) ;
|
|
309
|
+
debounce(func, delay) {
|
|
310
|
+
let timeout;
|
|
311
|
+
return () => {
|
|
312
|
+
clearTimeout(timeout);
|
|
313
|
+
timeout = setTimeout(() => func(), delay);
|
|
314
|
+
};
|
|
1083
315
|
}
|
|
1084
316
|
initializePlugins() {
|
|
1085
|
-
var _a
|
|
1086
|
-
const
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
if (((_b = this.props.infiniteScrollProps) === null || _b === void 0 ? void 0 : _b.enableInfiniteScroll) && !activePlugins.some(p => p.id === 'infinite-scroll')) {
|
|
1097
|
-
activePlugins.push(new InfiniteScrollPlugin());
|
|
1098
|
-
}
|
|
1099
|
-
activePlugins.forEach((plugin) => {
|
|
1100
|
-
if (plugin.onPluginInit) {
|
|
1101
|
-
plugin.onPluginInit({
|
|
1102
|
-
getData: () => this.props.data,
|
|
1103
|
-
forceUpdate: () => this.processData(),
|
|
1104
|
-
getScrollableElement: () => this.tableContainerRef.current,
|
|
1105
|
-
infiniteScrollProps: this.props.infiniteScrollProps,
|
|
1106
|
-
filterProps: this.props.filterProps,
|
|
1107
|
-
columnDefinitions: this.props.columnDefinitions,
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
});
|
|
1111
|
-
// Process data with all active plugins
|
|
1112
|
-
let processedData = [...this.props.data];
|
|
1113
|
-
activePlugins.forEach((plugin) => {
|
|
1114
|
-
if (plugin.processData) {
|
|
1115
|
-
processedData = plugin.processData(processedData);
|
|
1116
|
-
}
|
|
1117
|
-
});
|
|
1118
|
-
this.setState({ processedData });
|
|
1119
|
-
}
|
|
1120
|
-
processData() {
|
|
1121
|
-
let processedData = [...this.props.data];
|
|
1122
|
-
if (this.props.plugins) {
|
|
1123
|
-
this.props.plugins.forEach((plugin) => {
|
|
1124
|
-
if (plugin.processData) {
|
|
1125
|
-
processedData = plugin.processData(processedData);
|
|
1126
|
-
}
|
|
317
|
+
var _a;
|
|
318
|
+
const plugins = [];
|
|
319
|
+
if (this.props.plugins)
|
|
320
|
+
plugins.push(...this.props.plugins);
|
|
321
|
+
if (((_a = this.props.filterProps) === null || _a === void 0 ? void 0 : _a.showFilter) && !plugins.some(p => p.id === 'filter')) {
|
|
322
|
+
plugins.push(new FilterPlugin());
|
|
323
|
+
}
|
|
324
|
+
this.setState({ activePlugins: plugins }, () => {
|
|
325
|
+
plugins.forEach(plugin => {
|
|
326
|
+
var _a;
|
|
327
|
+
(_a = plugin.onPluginInit) === null || _a === void 0 ? void 0 : _a.call(plugin, Object.assign({ getData: () => this.state.internalData, forceUpdate: () => this.processData(), getScrollableElement: () => this.tableContainerRef.current }, this.props));
|
|
1127
328
|
});
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
}
|
|
1131
|
-
getColumnDefinition(columnDefinition, rowIndex) {
|
|
1132
|
-
if (!this.hasData) {
|
|
1133
|
-
return { displayLabel: '', cellRenderer: () => '' };
|
|
1134
|
-
}
|
|
1135
|
-
return columnDefinition instanceof Function ? columnDefinition(this.data[0], rowIndex) : columnDefinition;
|
|
1136
|
-
}
|
|
1137
|
-
getRawColumnDefinition(columnDefinition) {
|
|
1138
|
-
let rawColumnDefinition = {};
|
|
1139
|
-
if (columnDefinition instanceof Function) {
|
|
1140
|
-
rawColumnDefinition = columnDefinition(this.data[0], 0);
|
|
1141
|
-
}
|
|
1142
|
-
else {
|
|
1143
|
-
rawColumnDefinition = columnDefinition;
|
|
1144
|
-
}
|
|
1145
|
-
return rawColumnDefinition;
|
|
329
|
+
this.processData();
|
|
330
|
+
});
|
|
1146
331
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
if (rawColumnDefinition.interactivity && rawColumnDefinition.interactivity.onHeaderClick) {
|
|
1150
|
-
return rawColumnDefinition.interactivity.onHeaderClick;
|
|
1151
|
-
}
|
|
1152
|
-
else {
|
|
1153
|
-
return undefined;
|
|
1154
|
-
}
|
|
332
|
+
get data() {
|
|
333
|
+
return this.state.processedData || [];
|
|
1155
334
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
const clickableHeaderClassName = onHeaderClickCallback
|
|
1159
|
-
? rawColumnDefinition.interactivity.className || styles.clickableHeader
|
|
1160
|
-
: '';
|
|
1161
|
-
return clickableHeaderClassName;
|
|
335
|
+
get hasData() {
|
|
336
|
+
return this.data.length > 0;
|
|
1162
337
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
if (this.props.plugins) {
|
|
1166
|
-
this.props.plugins.forEach((plugin) => {
|
|
1167
|
-
if (plugin.getHeaderProps) {
|
|
1168
|
-
Object.assign(headerProps, plugin.getHeaderProps(this.getRawColumnDefinition(columnDefinition)));
|
|
1169
|
-
}
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
return headerProps;
|
|
338
|
+
get noDataComponent() {
|
|
339
|
+
return this.props.noDataComponent || React.createElement("div", { className: styles.noData }, "No data");
|
|
1173
340
|
}
|
|
1174
341
|
get rowClickFunction() {
|
|
1175
|
-
|
|
1176
|
-
return this.props.onRowClick;
|
|
1177
|
-
}
|
|
1178
|
-
else {
|
|
1179
|
-
return () => { };
|
|
1180
|
-
}
|
|
342
|
+
return this.props.onRowClick || (() => { });
|
|
1181
343
|
}
|
|
1182
344
|
get rowClickStyle() {
|
|
1183
|
-
|
|
1184
|
-
return { cursor: 'pointer' };
|
|
1185
|
-
}
|
|
1186
|
-
else {
|
|
1187
|
-
return {};
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
get tableFooter() {
|
|
1191
|
-
if (!this.props.footerRows || this.props.footerRows.length === 0) {
|
|
1192
|
-
return null;
|
|
1193
|
-
}
|
|
1194
|
-
return (React.createElement("tfoot", null, this.props.footerRows.map((row, rowIndex) => (React.createElement("tr", { key: rowIndex }, row.columns.map((col, colIndex) => (React.createElement("td", { key: colIndex, colSpan: col.colSpan, className: `${styles.footerCell} ${col.className || ''} ${col.onCellClick ? styles.clickableFooterCell : ''}`, onClick: col.onCellClick }, col.cellRenderer()))))))));
|
|
1195
|
-
}
|
|
1196
|
-
get mobileFooter() {
|
|
1197
|
-
if (!this.props.footerRows || this.props.footerRows.length === 0) {
|
|
1198
|
-
return null;
|
|
1199
|
-
}
|
|
1200
|
-
return (React.createElement("div", { className: styles.footerCard },
|
|
1201
|
-
React.createElement("div", { className: styles['footer-card-body'] }, this.props.footerRows.map((row, rowIndex) => {
|
|
1202
|
-
let currentColumnIndex = 0;
|
|
1203
|
-
return (React.createElement("div", { key: rowIndex }, row.columns.map((col, colIndex) => {
|
|
1204
|
-
let label = col.displayLabel;
|
|
1205
|
-
if (!label && col.colSpan === 1) {
|
|
1206
|
-
const header = this.props.columnDefinitions[currentColumnIndex];
|
|
1207
|
-
if (header) {
|
|
1208
|
-
label = this.getRawColumnDefinition(header).displayLabel;
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
currentColumnIndex += col.colSpan;
|
|
1212
|
-
return (React.createElement("p", { key: colIndex, className: `${styles['footer-card-row']} ${col.className || ''} ${col.onCellClick ? styles.clickableFooterCell : ''}`, onClick: col.onCellClick },
|
|
1213
|
-
label && React.createElement("span", { className: styles['card-label'] }, label),
|
|
1214
|
-
React.createElement("span", { className: styles['card-value'] }, col.cellRenderer())));
|
|
1215
|
-
})));
|
|
1216
|
-
}))));
|
|
1217
|
-
}
|
|
1218
|
-
get skeletonView() {
|
|
1219
|
-
const skeletonRowCount = 5; // Or make this configurable
|
|
1220
|
-
const columnCount = this.props.columnDefinitions.length;
|
|
1221
|
-
if (this.state.isMobile) {
|
|
1222
|
-
return (React.createElement("div", null, [...Array(skeletonRowCount)].map((_, i) => (React.createElement("div", { key: i, className: styles.skeletonCard }, [...Array(columnCount)].map((_, j) => (React.createElement("div", { key: j, className: `${styles.skeleton} ${styles.skeletonText}`, style: { marginBottom: '0.5rem' } }))))))));
|
|
1223
|
-
}
|
|
1224
|
-
return (React.createElement("table", { className: styles.responsiveTable },
|
|
1225
|
-
React.createElement("thead", null,
|
|
1226
|
-
React.createElement("tr", null, [...Array(columnCount)].map((_, i) => (React.createElement("th", { key: i },
|
|
1227
|
-
React.createElement("div", { className: `${styles.skeleton} ${styles.skeletonText}` })))))),
|
|
1228
|
-
React.createElement("tbody", null, [...Array(skeletonRowCount)].map((_, i) => (React.createElement("tr", { key: i }, [...Array(columnCount)].map((_, j) => (React.createElement("td", { key: j },
|
|
1229
|
-
React.createElement("div", { className: `${styles.skeleton} ${styles.skeletonText}` }))))))))));
|
|
345
|
+
return this.props.onRowClick ? { cursor: 'pointer' } : {};
|
|
1230
346
|
}
|
|
1231
347
|
get mobileView() {
|
|
1232
|
-
return (React.createElement("div", null,
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
const onHeaderClickCallback = this.onHeaderClickCallback(colDef);
|
|
1244
|
-
const clickableHeaderClassName = this.getClickableHeaderClassName(onHeaderClickCallback, colDef);
|
|
1245
|
-
return (React.createElement("div", { key: colIndex, className: styles['card-row'] },
|
|
1246
|
-
React.createElement("p", null,
|
|
1247
|
-
React.createElement("span", { className: `${styles['card-label']} ${clickableHeaderClassName}`, onClick: onHeaderClickCallback ? () => onHeaderClickCallback(colDef.interactivity.id) : undefined }, colDef.displayLabel),
|
|
1248
|
-
React.createElement("span", { className: styles['card-value'] }, colDef.cellRenderer(row)))));
|
|
1249
|
-
}))));
|
|
1250
|
-
}),
|
|
1251
|
-
this.mobileFooter));
|
|
348
|
+
return (React.createElement("div", null, this.data.map((row, rowIndex) => {
|
|
349
|
+
var _a;
|
|
350
|
+
return (React.createElement("div", { key: rowIndex, className: `${styles['card']} ${((_a = this.props.animationProps) === null || _a === void 0 ? void 0 : _a.animateOnLoad) ? styles.animatedRow : ''}`, style: { animationDelay: `${rowIndex * 0.05}s` }, onClick: () => this.rowClickFunction(row) },
|
|
351
|
+
React.createElement("div", { className: styles['card-body'] }, this.props.columnDefinitions.map((colDef, colIndex) => {
|
|
352
|
+
const column = this.getColumnDefinition(colDef, rowIndex);
|
|
353
|
+
return (React.createElement("div", { key: colIndex, className: styles['card-row'] },
|
|
354
|
+
React.createElement("p", null,
|
|
355
|
+
React.createElement("span", { className: styles['card-label'] }, column.displayLabel),
|
|
356
|
+
React.createElement("span", { className: styles['card-value'] }, column.cellRenderer(row)))));
|
|
357
|
+
}))));
|
|
358
|
+
})));
|
|
1252
359
|
}
|
|
1253
360
|
get largeScreenView() {
|
|
1254
|
-
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
columnWidths: this.state.columnWidths,
|
|
1261
|
-
columnDefinitions: this.props.columnDefinitions,
|
|
1262
|
-
animationProps: this.props.animationProps,
|
|
1263
|
-
getColumnDefinition: this.getColumnDefinition.bind(this),
|
|
1264
|
-
rowClickFunction: this.rowClickFunction,
|
|
1265
|
-
rowClickStyle: this.rowClickStyle,
|
|
1266
|
-
};
|
|
1267
|
-
return (React.createElement("div", { style: fixedHeadersStyle, ref: this.tableContainerRef },
|
|
1268
|
-
React.createElement("table", { className: styles['responsiveTable'], style: { tableLayout: 'fixed' } },
|
|
361
|
+
var _a;
|
|
362
|
+
const { infiniteScrollProps } = this.props;
|
|
363
|
+
const { isLoadingMore } = this.state;
|
|
364
|
+
const hasMore = ((_a = this.props.infiniteScrollProps) === null || _a === void 0 ? void 0 : _a.hasMore) !== undefined ? this.props.infiniteScrollProps.hasMore : this.state.internalHasMore;
|
|
365
|
+
return (React.createElement("div", { ref: this.tableContainerRef, onScroll: this.throttledScrollHandler, style: { maxHeight: this.props.maxHeight, overflowY: 'auto' } },
|
|
366
|
+
React.createElement("table", { className: styles['responsiveTable'] },
|
|
1269
367
|
React.createElement("thead", { ref: this.headerRef, className: this.state.isHeaderSticky ? styles.stickyHeader : '' },
|
|
1270
|
-
React.createElement("tr", null, this.props.columnDefinitions.map((
|
|
1271
|
-
const
|
|
1272
|
-
const
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
const combinedClassName = `${clickableHeaderClassName} ${headerProps.className ? styles[headerProps.className] : ''}`.trim();
|
|
1276
|
-
// Remove className from headerProps to avoid duplication
|
|
368
|
+
React.createElement("tr", null, this.props.columnDefinitions.map((colDef, colIndex) => {
|
|
369
|
+
const rawColDef = this.getRawColumnDefinition(colDef);
|
|
370
|
+
const headerProps = this.getHeaderProps(rawColDef);
|
|
371
|
+
const onHeaderClickCallback = this.onHeaderClickCallback(rawColDef);
|
|
372
|
+
const combinedClassName = `${this.getClickableHeaderClassName(rawColDef)} ${headerProps.className ? styles[headerProps.className] : ''}`.trim();
|
|
1277
373
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1278
374
|
const { className } = headerProps, restHeaderProps = __rest(headerProps, ["className"]);
|
|
1279
|
-
return (React.createElement("th", Object.assign({ key: colIndex, className: combinedClassName }, restHeaderProps, {
|
|
375
|
+
return (React.createElement("th", Object.assign({ key: colIndex, className: combinedClassName }, restHeaderProps, { onClick: onHeaderClickCallback ? () => onHeaderClickCallback(rawColDef.interactivity.id) : undefined }),
|
|
1280
376
|
React.createElement("div", { className: styles.headerInnerWrapper },
|
|
1281
|
-
React.createElement("div", { className: styles.headerContent },
|
|
377
|
+
React.createElement("div", { className: styles.headerContent }, rawColDef.displayLabel),
|
|
1282
378
|
React.createElement("span", { className: styles.sortIcon }))));
|
|
1283
379
|
}))),
|
|
1284
|
-
React.createElement(
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
React.createElement("span", { style: Object.assign({}, rowClickStyle) }, getColumnDefinition(columnDefinition, index).cellRenderer(row)))))));
|
|
1291
|
-
}),
|
|
1292
|
-
this.tableFooter),
|
|
1293
|
-
this.renderPluginFooters()));
|
|
1294
|
-
}
|
|
1295
|
-
renderPluginHeaders() {
|
|
1296
|
-
if (!this.props.plugins) {
|
|
1297
|
-
return null;
|
|
1298
|
-
}
|
|
1299
|
-
return this.props.plugins.map((plugin) => {
|
|
1300
|
-
if (plugin.renderHeader) {
|
|
1301
|
-
// For sort plugin, only render header in mobile view
|
|
1302
|
-
if (plugin.id === 'sort' && !this.state.isMobile) {
|
|
1303
|
-
return null;
|
|
1304
|
-
}
|
|
1305
|
-
return React.createElement("div", { key: plugin.id }, plugin.renderHeader());
|
|
1306
|
-
}
|
|
1307
|
-
return null;
|
|
1308
|
-
});
|
|
1309
|
-
}
|
|
1310
|
-
renderPluginFooters() {
|
|
1311
|
-
if (!this.props.plugins) {
|
|
1312
|
-
return null;
|
|
1313
|
-
}
|
|
1314
|
-
return this.props.plugins.map((plugin) => {
|
|
1315
|
-
if (plugin.renderFooter) {
|
|
1316
|
-
return React.createElement("div", { key: plugin.id + '-footer' }, plugin.renderFooter());
|
|
1317
|
-
}
|
|
1318
|
-
return null;
|
|
1319
|
-
});
|
|
380
|
+
React.createElement("tbody", null, this.data.map((row, rowIndex) => {
|
|
381
|
+
var _a;
|
|
382
|
+
return (React.createElement("tr", { key: rowIndex, className: ((_a = this.props.animationProps) === null || _a === void 0 ? void 0 : _a.animateOnLoad) ? styles.animatedRow : '', style: { animationDelay: `${rowIndex * 0.05}s` } }, this.props.columnDefinitions.map((colDef, colIndex) => (React.createElement("td", { key: colIndex, onClick: () => this.rowClickFunction(row), style: this.rowClickStyle }, this.getColumnDefinition(colDef, rowIndex).cellRenderer(row))))));
|
|
383
|
+
}))),
|
|
384
|
+
isLoadingMore && (infiniteScrollProps === null || infiniteScrollProps === void 0 ? void 0 : infiniteScrollProps.loadingMoreComponent),
|
|
385
|
+
!isLoadingMore && !hasMore && (infiniteScrollProps === null || infiniteScrollProps === void 0 ? void 0 : infiniteScrollProps.noMoreDataComponent)));
|
|
1320
386
|
}
|
|
1321
387
|
render() {
|
|
1322
388
|
var _a;
|
|
1323
|
-
if ((_a = this.props.animationProps) === null || _a === void 0 ? void 0 : _a.isLoading) {
|
|
1324
|
-
return
|
|
389
|
+
if (((_a = this.props.animationProps) === null || _a === void 0 ? void 0 : _a.isLoading) && !this.hasData) {
|
|
390
|
+
return React.createElement("div", null, "Skeleton View Placeholder");
|
|
1325
391
|
}
|
|
1326
392
|
return (React.createElement("div", null,
|
|
1327
|
-
this.renderPluginHeaders(),
|
|
1328
393
|
!this.hasData && this.noDataComponent,
|
|
1329
|
-
this.hasData && this.state.isMobile
|
|
1330
|
-
this.hasData && !this.state.isMobile && this.largeScreenView));
|
|
394
|
+
this.hasData && (this.state.isMobile ? this.mobileView : this.largeScreenView)));
|
|
1331
395
|
}
|
|
1332
396
|
}
|
|
1333
397
|
|
|
@@ -1404,12 +468,9 @@ class ResponsiveTable extends React.Component {
|
|
|
1404
468
|
}
|
|
1405
469
|
}
|
|
1406
470
|
componentDidUpdate(prevProps) {
|
|
1407
|
-
var _a, _b, _c;
|
|
1408
471
|
if (prevProps.data !== this.props.data) {
|
|
1409
472
|
this.processData();
|
|
1410
473
|
}
|
|
1411
|
-
// Handle infinite scroll loading
|
|
1412
|
-
if (((_a = this.props.infiniteScrollProps) === null || _a === void 0 ? void 0 : _a.enableInfiniteScroll) && ((_b = this.props.infiniteScrollProps) === null || _b === void 0 ? void 0 : _b.hasMore) && !this.state.isLoadingMore && ((_c = this.props.infiniteScrollProps) === null || _c === void 0 ? void 0 : _c.onLoadMore)) ;
|
|
1413
474
|
}
|
|
1414
475
|
initializePlugins() {
|
|
1415
476
|
var _a, _b;
|