react-ui89 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useState, useMemo } from 'react';
2
+ import React__default, { useState, useMemo, createElement, PureComponent, Component, forwardRef } from 'react';
3
3
 
4
4
  var Ui89Theme;
5
5
  (function (Ui89Theme) {
@@ -16,18 +16,18 @@ var Ui89Look;
16
16
  Ui89Look["side"] = "side";
17
17
  })(Ui89Look || (Ui89Look = {}));
18
18
 
19
- var styles$a = {"container":"Ui89Button-module_container__V4tWM","button":"Ui89Button-module_button__wl9cp","block":"Ui89Button-module_block__3sGjT","disabled":"Ui89Button-module_disabled__I5nOu","active":"Ui89Button-module_active__ZN0AN","size--normal":"Ui89Button-module_size--normal__Pht3J","size--small":"Ui89Button-module_size--small__-4-4v","click":"Ui89Button-module_click__INMSh"};
19
+ var styles$b = {"container":"Ui89Button-module_container__V4tWM","button":"Ui89Button-module_button__wl9cp","block":"Ui89Button-module_block__3sGjT","disabled":"Ui89Button-module_disabled__I5nOu","active":"Ui89Button-module_active__ZN0AN","size--normal":"Ui89Button-module_size--normal__Pht3J","size--small":"Ui89Button-module_size--small__-4-4v","click":"Ui89Button-module_click__INMSh"};
20
20
 
21
21
  var typoStyles = {"big":"typo-module_big__NWXQv","normal":"typo-module_normal__a1-s-","normalBold":"typo-module_normalBold__6Mx0C","small":"typo-module_small__cdnMc","smallBold":"typo-module_smallBold__BRDCu","special":"typo-module_special__PiPuc"};
22
22
 
23
23
  var chosenThemeStyles = {"primary":"chosen-theme-module_primary__GwEqU","secondary":"chosen-theme-module_secondary__DI5Gk","info":"chosen-theme-module_info__KYP2h","success":"chosen-theme-module_success__l3hFS","warning":"chosen-theme-module_warning__A7IOL","danger":"chosen-theme-module_danger__CZ3Iq"};
24
24
 
25
- var styles$9 = {"hoverShadow":"HoverShadow-module_hoverShadow__-cRBn","hoverShadowRight":"HoverShadow-module_hoverShadowRight__u1rW-","hoverShadowBottom":"HoverShadow-module_hoverShadowBottom__mTTdA"};
25
+ var styles$a = {"hoverShadow":"HoverShadow-module_hoverShadow__-cRBn","hoverShadowRight":"HoverShadow-module_hoverShadowRight__u1rW-","hoverShadowBottom":"HoverShadow-module_hoverShadowBottom__mTTdA"};
26
26
 
27
27
  function HoverShadow({ children, }) {
28
- return (React__default.createElement("span", { className: styles$9.hoverShadow },
29
- React__default.createElement("span", { className: styles$9.hoverShadowBottom }),
30
- React__default.createElement("span", { className: styles$9.hoverShadowRight }),
28
+ return (React__default.createElement("span", { className: styles$a.hoverShadow },
29
+ React__default.createElement("span", { className: styles$a.hoverShadowBottom }),
30
+ React__default.createElement("span", { className: styles$a.hoverShadowRight }),
31
31
  children));
32
32
  }
33
33
 
@@ -81,39 +81,39 @@ function Ui89Button({ theme = Ui89Theme.primary, size = "normal", block, onClick
81
81
  }
82
82
  }
83
83
  let buttonClass = [
84
- styles$a.button,
84
+ styles$b.button,
85
85
  typoStyles.special,
86
86
  chosenThemeStyles[theme],
87
- styles$a["size--" + size],
88
- activated ? styles$a.active : undefined,
89
- block ? styles$a.block : undefined,
90
- disabled ? styles$a.disabled : undefined,
91
- clicking ? styles$a.active : undefined,
87
+ styles$b["size--" + size],
88
+ activated ? styles$b.active : undefined,
89
+ block ? styles$b.block : undefined,
90
+ disabled ? styles$b.disabled : undefined,
91
+ clicking ? styles$b.active : undefined,
92
92
  ].join(" ");
93
93
  if (href) {
94
- return (React__default.createElement("span", { className: styles$a.container },
94
+ return (React__default.createElement("span", { className: styles$b.container },
95
95
  React__default.createElement(HoverShadow, null,
96
96
  React__default.createElement("a", { className: buttonClass, href: href, onClick: onAnchorClick },
97
- React__default.createElement("span", { className: styles$a.click }),
97
+ React__default.createElement("span", { className: styles$b.click }),
98
98
  children))));
99
99
  }
100
100
  else {
101
- return (React__default.createElement("span", { className: styles$a.container },
101
+ return (React__default.createElement("span", { className: styles$b.container },
102
102
  React__default.createElement(HoverShadow, null,
103
103
  React__default.createElement("button", { className: buttonClass, type: "button", onClick: onButtonClick, disabled: localDisabled },
104
- React__default.createElement("span", { className: styles$a.click }),
104
+ React__default.createElement("span", { className: styles$b.click }),
105
105
  children))));
106
106
  }
107
107
  }
108
108
 
109
- var styles$8 = {"container":"Ui89Card-module_container__-8hhJ","containerHasTop":"Ui89Card-module_containerHasTop__UsQUD","inside":"Ui89Card-module_inside__91GoJ","topLeftCenter":"Ui89Card-module_topLeftCenter__r9PD6","topCenter":"Ui89Card-module_topCenter__SZWfR"};
109
+ var styles$9 = {"container":"Ui89Card-module_container__-8hhJ","containerHasTop":"Ui89Card-module_containerHasTop__UsQUD","inside":"Ui89Card-module_inside__91GoJ","topLeftCenter":"Ui89Card-module_topLeftCenter__r9PD6","topCenter":"Ui89Card-module_topCenter__SZWfR"};
110
110
 
111
111
  function Ui89Card({ topLeftCenter, topCenter, children, }) {
112
112
  const hasTopContent = topLeftCenter || topCenter;
113
- return (React__default.createElement("div", { className: `${styles$8.container} ${hasTopContent ? styles$8.containerHasTop : ""}` },
114
- React__default.createElement("div", { className: styles$8.inside },
115
- topLeftCenter && (React__default.createElement("div", { className: styles$8.topLeftCenter }, topLeftCenter)),
116
- topCenter && React__default.createElement("div", { className: styles$8.topCenter }, topCenter),
113
+ return (React__default.createElement("div", { className: `${styles$9.container} ${hasTopContent ? styles$9.containerHasTop : ""}` },
114
+ React__default.createElement("div", { className: styles$9.inside },
115
+ topLeftCenter && (React__default.createElement("div", { className: styles$9.topLeftCenter }, topLeftCenter)),
116
+ topCenter && React__default.createElement("div", { className: styles$9.topCenter }, topCenter),
117
117
  hasTopContent && React__default.createElement("div", { className: "space-vertical-1" }),
118
118
  children,
119
119
  hasTopContent && React__default.createElement("div", { className: "space-vertical-1" }))));
@@ -34212,39 +34212,39 @@ function requireLib () {
34212
34212
  var libExports = requireLib();
34213
34213
  var ReactModal = /*@__PURE__*/getDefaultExportFromCjs(libExports);
34214
34214
 
34215
- var styles$7 = {"container":"Ui89ModalDialog-module_container__-azd7","appear":"Ui89ModalDialog-module_appear__Xt-kk","backdrop":"Ui89ModalDialog-module_backdrop__Hg1Dn","spacer":"Ui89ModalDialog-module_spacer__fS17b","container--size-big":"Ui89ModalDialog-module_container--size-big__03rgP","container--size-medium":"Ui89ModalDialog-module_container--size-medium__A3TJY","container--size-small":"Ui89ModalDialog-module_container--size-small__mxNgm"};
34215
+ var styles$8 = {"container":"Ui89ModalDialog-module_container__-azd7","appear":"Ui89ModalDialog-module_appear__Xt-kk","backdrop":"Ui89ModalDialog-module_backdrop__Hg1Dn","spacer":"Ui89ModalDialog-module_spacer__fS17b","container--size-big":"Ui89ModalDialog-module_container--size-big__03rgP","container--size-medium":"Ui89ModalDialog-module_container--size-medium__A3TJY","container--size-small":"Ui89ModalDialog-module_container--size-small__mxNgm"};
34216
34216
 
34217
- var styles$6 = {"scene":"Ui89Scene-module_scene__5uNRp"};
34217
+ var styles$7 = {"scene":"Ui89Scene-module_scene__5uNRp"};
34218
34218
 
34219
34219
  var lookStyles = {"main":"look-module_main__dCtZk","side":"look-module_side__bCbry"};
34220
34220
 
34221
34221
  var scrollbarStyles = {"container":"scrollbar-module_container__q4x0n"};
34222
34222
 
34223
34223
  function Ui89Scene({ look = Ui89Look.main, children, }) {
34224
- return (React__default.createElement("div", { className: `${styles$6.scene} ${lookStyles[look]} ${typoStyles.normal} ${scrollbarStyles.container}` }, children));
34224
+ return (React__default.createElement("div", { className: `${styles$7.scene} ${lookStyles[look]} ${typoStyles.normal} ${scrollbarStyles.container}` }, children));
34225
34225
  }
34226
34226
 
34227
- var styles$5 = {"gridExpandTrick":"GridExpandTrick-module_gridExpandTrick__10Eg5"};
34227
+ var styles$6 = {"gridExpandTrick":"GridExpandTrick-module_gridExpandTrick__10Eg5"};
34228
34228
 
34229
34229
  function GridExpandTrick({ children, }) {
34230
- return React__default.createElement("span", { className: styles$5.gridExpandTrick }, children);
34230
+ return React__default.createElement("span", { className: styles$6.gridExpandTrick }, children);
34231
34231
  }
34232
34232
 
34233
- var styles$4 = {"scrollContainer":"ScrollContainer-module_scrollContainer__J82cj"};
34233
+ var styles$5 = {"scrollContainer":"ScrollContainer-module_scrollContainer__J82cj"};
34234
34234
 
34235
34235
  function ScrollContainer({ children, }) {
34236
- return React__default.createElement("span", { className: styles$4.scrollContainer }, children);
34236
+ return React__default.createElement("span", { className: styles$5.scrollContainer }, children);
34237
34237
  }
34238
34238
 
34239
34239
  // @ts-ignore
34240
34240
  function Ui89ModalDialog({ open, size = "medium", children, topCenter, onClose, onRequestClose, }) {
34241
34241
  const className = useMemo(() => {
34242
- return [styles$7.container, styles$7[`container--size-${size}`]].join(" ");
34242
+ return [styles$8.container, styles$8[`container--size-${size}`]].join(" ");
34243
34243
  }, [size]);
34244
- return (React__default.createElement(ReactModal, { className: className, overlayClassName: styles$7.backdrop, isOpen: open, onAfterClose: onClose, onRequestClose: onRequestClose,
34244
+ return (React__default.createElement(ReactModal, { className: className, overlayClassName: styles$8.backdrop, isOpen: open, onAfterClose: onClose, onRequestClose: onRequestClose,
34245
34245
  // So it shuts up.
34246
34246
  ariaHideApp: false },
34247
- React__default.createElement("div", { className: styles$7.spacer }),
34247
+ React__default.createElement("div", { className: styles$8.spacer }),
34248
34248
  React__default.createElement(HoverShadow, null,
34249
34249
  React__default.createElement(GridExpandTrick, null,
34250
34250
  React__default.createElement(Ui89Scene, { look: "side" },
@@ -34253,8 +34253,8 @@ function Ui89ModalDialog({ open, size = "medium", children, topCenter, onClose,
34253
34253
  }
34254
34254
 
34255
34255
  var _path, _path2;
34256
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
34257
- const SvgShortcut = props => /*#__PURE__*/React.createElement("svg", _extends({
34256
+ function _extends$1() { return _extends$1 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$1.apply(null, arguments); }
34257
+ const SvgShortcut = props => /*#__PURE__*/React.createElement("svg", _extends$1({
34258
34258
  xmlns: "http://www.w3.org/2000/svg",
34259
34259
  width: 100,
34260
34260
  height: 100
@@ -34269,15 +34269,15 @@ const SvgShortcut = props => /*#__PURE__*/React.createElement("svg", _extends({
34269
34269
  d: "M20 20h30M20 20v30"
34270
34270
  })));
34271
34271
 
34272
- var styles$3 = {"container":"Ui89Shortcut-module_container__L07CL","image":"Ui89Shortcut-module_image__f4Hsg","shortcutIcon":"Ui89Shortcut-module_shortcutIcon__SjZkr"};
34272
+ var styles$4 = {"container":"Ui89Shortcut-module_container__L07CL","image":"Ui89Shortcut-module_image__f4Hsg","shortcutIcon":"Ui89Shortcut-module_shortcutIcon__SjZkr"};
34273
34273
 
34274
34274
  function Ui89Shortcut({ imageUrl, label, onClick = () => { }, }) {
34275
34275
  function onNativeClick() {
34276
34276
  onClick();
34277
34277
  }
34278
- return (React__default.createElement("div", { className: styles$3.container },
34279
- React__default.createElement("img", { className: styles$3.image, src: imageUrl, onClick: onNativeClick }),
34280
- React__default.createElement(SvgShortcut, { className: styles$3.shortcutIcon, width: 16, height: 16 }),
34278
+ return (React__default.createElement("div", { className: styles$4.container },
34279
+ React__default.createElement("img", { className: styles$4.image, src: imageUrl, onClick: onNativeClick }),
34280
+ React__default.createElement(SvgShortcut, { className: styles$4.shortcutIcon, width: 16, height: 16 }),
34281
34281
  React__default.createElement("div", { className: `${typoStyles.smallBold}` }, label)));
34282
34282
  }
34283
34283
 
@@ -34288,16 +34288,16 @@ function Ui89SpaceVertical({ gap = 1 }) {
34288
34288
  return React__default.createElement("div", { style: style });
34289
34289
  }
34290
34290
 
34291
- var styles$2 = {"navigation":"Ui89Tabs-module_navigation__y1WSG","navigationItem":"Ui89Tabs-module_navigationItem__keX-1","navigationItemSelected":"Ui89Tabs-module_navigationItemSelected__R7dba"};
34291
+ var styles$3 = {"navigation":"Ui89Tabs-module_navigation__y1WSG","navigationItem":"Ui89Tabs-module_navigationItem__keX-1","navigationItemSelected":"Ui89Tabs-module_navigationItemSelected__R7dba"};
34292
34292
 
34293
34293
  function Ui89Tabs({ selected, onChange = () => { }, items = [], }) {
34294
34294
  function handleOnChange(value) {
34295
34295
  onChange(value);
34296
34296
  }
34297
- return (React__default.createElement("div", { className: styles$2.navigation }, items.map((item) => (React__default.createElement("div", { className: [
34298
- styles$2.navigationItem,
34297
+ return (React__default.createElement("div", { className: styles$3.navigation }, items.map((item) => (React__default.createElement("div", { className: [
34298
+ styles$3.navigationItem,
34299
34299
  typoStyles.smallBold,
34300
- selected === item.value ? styles$2.navigationItemSelected : "",
34300
+ selected === item.value ? styles$3.navigationItemSelected : "",
34301
34301
  ].join(" "), key: item.value, onClick: () => handleOnChange(item.value) }, item.label)))));
34302
34302
  }
34303
34303
 
@@ -34318,21 +34318,1534 @@ function Ui89TagBox({ theme, children, }) {
34318
34318
  return (React__default.createElement("div", { className: `${style.container} ${typoStyles.special} ${chosenThemeStyles[theme]}` }, children));
34319
34319
  }
34320
34320
 
34321
- var styles$1 = {"container":"Ui89TitleBox-module_container__M-b7J","inside":"Ui89TitleBox-module_inside__GWTlP"};
34321
+ var styles$2 = {"container":"Ui89TitleBox-module_container__M-b7J","inside":"Ui89TitleBox-module_inside__GWTlP"};
34322
34322
 
34323
34323
  var textStyles = {"unbreakable":"text-module_unbreakable__3eDe3","ellipsis":"text-module_ellipsis__3-f-B","singleLine":"text-module_singleLine__X6pYL"};
34324
34324
 
34325
34325
  function Ui89TitleBox({ children }) {
34326
+ return (React__default.createElement("div", { className: `${styles$2.container} ${typoStyles.special}` },
34327
+ React__default.createElement("div", { className: `${styles$2.inside} ${textStyles.singleLine}` }, children)));
34328
+ }
34329
+
34330
+ var styles$1 = {"container":"Ui89TitleUnderline-module_container__EaGZi","inside":"Ui89TitleUnderline-module_inside__uwwxa"};
34331
+
34332
+ function Ui89TitleUnderline({ children, }) {
34326
34333
  return (React__default.createElement("div", { className: `${styles$1.container} ${typoStyles.special}` },
34327
34334
  React__default.createElement("div", { className: `${styles$1.inside} ${textStyles.singleLine}` }, children)));
34328
34335
  }
34329
34336
 
34330
- var styles = {"container":"Ui89TitleUnderline-module_container__EaGZi","inside":"Ui89TitleUnderline-module_inside__uwwxa"};
34337
+ function _extends() {
34338
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
34339
+ for (var e = 1; e < arguments.length; e++) {
34340
+ var t = arguments[e];
34341
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
34342
+ }
34343
+ return n;
34344
+ }, _extends.apply(null, arguments);
34345
+ }
34331
34346
 
34332
- function Ui89TitleUnderline({ children, }) {
34333
- return (React__default.createElement("div", { className: `${styles.container} ${typoStyles.special}` },
34334
- React__default.createElement("div", { className: `${styles.inside} ${textStyles.singleLine}` }, children)));
34347
+ function _assertThisInitialized(e) {
34348
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
34349
+ return e;
34350
+ }
34351
+
34352
+ function _setPrototypeOf(t, e) {
34353
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
34354
+ return t.__proto__ = e, t;
34355
+ }, _setPrototypeOf(t, e);
34356
+ }
34357
+
34358
+ function _inheritsLoose(t, o) {
34359
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
34360
+ }
34361
+
34362
+ var safeIsNaN = Number.isNaN ||
34363
+ function ponyfill(value) {
34364
+ return typeof value === 'number' && value !== value;
34365
+ };
34366
+ function isEqual(first, second) {
34367
+ if (first === second) {
34368
+ return true;
34369
+ }
34370
+ if (safeIsNaN(first) && safeIsNaN(second)) {
34371
+ return true;
34372
+ }
34373
+ return false;
34374
+ }
34375
+ function areInputsEqual(newInputs, lastInputs) {
34376
+ if (newInputs.length !== lastInputs.length) {
34377
+ return false;
34378
+ }
34379
+ for (var i = 0; i < newInputs.length; i++) {
34380
+ if (!isEqual(newInputs[i], lastInputs[i])) {
34381
+ return false;
34382
+ }
34383
+ }
34384
+ return true;
34385
+ }
34386
+
34387
+ function memoizeOne(resultFn, isEqual) {
34388
+ if (isEqual === void 0) { isEqual = areInputsEqual; }
34389
+ var lastThis;
34390
+ var lastArgs = [];
34391
+ var lastResult;
34392
+ var calledOnce = false;
34393
+ function memoized() {
34394
+ var newArgs = [];
34395
+ for (var _i = 0; _i < arguments.length; _i++) {
34396
+ newArgs[_i] = arguments[_i];
34397
+ }
34398
+ if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
34399
+ return lastResult;
34400
+ }
34401
+ lastResult = resultFn.apply(this, newArgs);
34402
+ calledOnce = true;
34403
+ lastThis = this;
34404
+ lastArgs = newArgs;
34405
+ return lastResult;
34406
+ }
34407
+ return memoized;
34408
+ }
34409
+
34410
+ // Animation frame based implementation of setTimeout.
34411
+ // Inspired by Joe Lambert, https://gist.github.com/joelambert/1002116#file-requesttimeout-js
34412
+ var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
34413
+ var now = hasNativePerformanceNow ? function () {
34414
+ return performance.now();
34415
+ } : function () {
34416
+ return Date.now();
34417
+ };
34418
+ function cancelTimeout(timeoutID) {
34419
+ cancelAnimationFrame(timeoutID.id);
34420
+ }
34421
+ function requestTimeout(callback, delay) {
34422
+ var start = now();
34423
+
34424
+ function tick() {
34425
+ if (now() - start >= delay) {
34426
+ callback.call(null);
34427
+ } else {
34428
+ timeoutID.id = requestAnimationFrame(tick);
34429
+ }
34430
+ }
34431
+
34432
+ var timeoutID = {
34433
+ id: requestAnimationFrame(tick)
34434
+ };
34435
+ return timeoutID;
34436
+ }
34437
+
34438
+ var size = -1; // This utility copied from "dom-helpers" package.
34439
+
34440
+ function getScrollbarSize(recalculate) {
34441
+ if (recalculate === void 0) {
34442
+ recalculate = false;
34443
+ }
34444
+
34445
+ if (size === -1 || recalculate) {
34446
+ var div = document.createElement('div');
34447
+ var style = div.style;
34448
+ style.width = '50px';
34449
+ style.height = '50px';
34450
+ style.overflow = 'scroll';
34451
+ document.body.appendChild(div);
34452
+ size = div.offsetWidth - div.clientWidth;
34453
+ document.body.removeChild(div);
34454
+ }
34455
+
34456
+ return size;
34457
+ }
34458
+ var cachedRTLResult = null; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
34459
+ // Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
34460
+ // Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
34461
+ // The safest way to check this is to intentionally set a negative offset,
34462
+ // and then verify that the subsequent "scroll" event matches the negative offset.
34463
+ // If it does not match, then we can assume a non-standard RTL scroll implementation.
34464
+
34465
+ function getRTLOffsetType(recalculate) {
34466
+ if (recalculate === void 0) {
34467
+ recalculate = false;
34468
+ }
34469
+
34470
+ if (cachedRTLResult === null || recalculate) {
34471
+ var outerDiv = document.createElement('div');
34472
+ var outerStyle = outerDiv.style;
34473
+ outerStyle.width = '50px';
34474
+ outerStyle.height = '50px';
34475
+ outerStyle.overflow = 'scroll';
34476
+ outerStyle.direction = 'rtl';
34477
+ var innerDiv = document.createElement('div');
34478
+ var innerStyle = innerDiv.style;
34479
+ innerStyle.width = '100px';
34480
+ innerStyle.height = '100px';
34481
+ outerDiv.appendChild(innerDiv);
34482
+ document.body.appendChild(outerDiv);
34483
+
34484
+ if (outerDiv.scrollLeft > 0) {
34485
+ cachedRTLResult = 'positive-descending';
34486
+ } else {
34487
+ outerDiv.scrollLeft = 1;
34488
+
34489
+ if (outerDiv.scrollLeft === 0) {
34490
+ cachedRTLResult = 'negative';
34491
+ } else {
34492
+ cachedRTLResult = 'positive-ascending';
34493
+ }
34494
+ }
34495
+
34496
+ document.body.removeChild(outerDiv);
34497
+ return cachedRTLResult;
34498
+ }
34499
+
34500
+ return cachedRTLResult;
34501
+ }
34502
+
34503
+ var IS_SCROLLING_DEBOUNCE_INTERVAL = 150;
34504
+
34505
+ var defaultItemKey = function defaultItemKey(_ref) {
34506
+ var columnIndex = _ref.columnIndex;
34507
+ _ref.data;
34508
+ var rowIndex = _ref.rowIndex;
34509
+ return rowIndex + ":" + columnIndex;
34510
+ }; // In DEV mode, this Set helps us only log a warning once per component instance.
34511
+ // This avoids spamming the console every time a render happens.
34512
+
34513
+
34514
+ var devWarningsOverscanCount = null;
34515
+ var devWarningsOverscanRowsColumnsCount = null;
34516
+ var devWarningsTagName = null;
34517
+
34518
+ if (process.env.NODE_ENV !== 'production') {
34519
+ if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
34520
+ devWarningsOverscanCount = /*#__PURE__*/new WeakSet();
34521
+ devWarningsOverscanRowsColumnsCount = /*#__PURE__*/new WeakSet();
34522
+ devWarningsTagName = /*#__PURE__*/new WeakSet();
34523
+ }
34524
+ }
34525
+
34526
+ function createGridComponent(_ref2) {
34527
+ var _class;
34528
+
34529
+ var getColumnOffset = _ref2.getColumnOffset,
34530
+ getColumnStartIndexForOffset = _ref2.getColumnStartIndexForOffset,
34531
+ getColumnStopIndexForStartIndex = _ref2.getColumnStopIndexForStartIndex,
34532
+ getColumnWidth = _ref2.getColumnWidth,
34533
+ getEstimatedTotalHeight = _ref2.getEstimatedTotalHeight,
34534
+ getEstimatedTotalWidth = _ref2.getEstimatedTotalWidth,
34535
+ getOffsetForColumnAndAlignment = _ref2.getOffsetForColumnAndAlignment,
34536
+ getOffsetForRowAndAlignment = _ref2.getOffsetForRowAndAlignment,
34537
+ getRowHeight = _ref2.getRowHeight,
34538
+ getRowOffset = _ref2.getRowOffset,
34539
+ getRowStartIndexForOffset = _ref2.getRowStartIndexForOffset,
34540
+ getRowStopIndexForStartIndex = _ref2.getRowStopIndexForStartIndex,
34541
+ initInstanceProps = _ref2.initInstanceProps,
34542
+ shouldResetStyleCacheOnItemSizeChange = _ref2.shouldResetStyleCacheOnItemSizeChange,
34543
+ validateProps = _ref2.validateProps;
34544
+ return _class = /*#__PURE__*/function (_PureComponent) {
34545
+ _inheritsLoose(Grid, _PureComponent);
34546
+
34547
+ // Always use explicit constructor for React components.
34548
+ // It produces less code after transpilation. (#26)
34549
+ // eslint-disable-next-line no-useless-constructor
34550
+ function Grid(props) {
34551
+ var _this;
34552
+
34553
+ _this = _PureComponent.call(this, props) || this;
34554
+ _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
34555
+ _this._resetIsScrollingTimeoutId = null;
34556
+ _this._outerRef = void 0;
34557
+ _this.state = {
34558
+ instance: _assertThisInitialized(_this),
34559
+ isScrolling: false,
34560
+ horizontalScrollDirection: 'forward',
34561
+ scrollLeft: typeof _this.props.initialScrollLeft === 'number' ? _this.props.initialScrollLeft : 0,
34562
+ scrollTop: typeof _this.props.initialScrollTop === 'number' ? _this.props.initialScrollTop : 0,
34563
+ scrollUpdateWasRequested: false,
34564
+ verticalScrollDirection: 'forward'
34565
+ };
34566
+ _this._callOnItemsRendered = void 0;
34567
+ _this._callOnItemsRendered = memoizeOne(function (overscanColumnStartIndex, overscanColumnStopIndex, overscanRowStartIndex, overscanRowStopIndex, visibleColumnStartIndex, visibleColumnStopIndex, visibleRowStartIndex, visibleRowStopIndex) {
34568
+ return _this.props.onItemsRendered({
34569
+ overscanColumnStartIndex: overscanColumnStartIndex,
34570
+ overscanColumnStopIndex: overscanColumnStopIndex,
34571
+ overscanRowStartIndex: overscanRowStartIndex,
34572
+ overscanRowStopIndex: overscanRowStopIndex,
34573
+ visibleColumnStartIndex: visibleColumnStartIndex,
34574
+ visibleColumnStopIndex: visibleColumnStopIndex,
34575
+ visibleRowStartIndex: visibleRowStartIndex,
34576
+ visibleRowStopIndex: visibleRowStopIndex
34577
+ });
34578
+ });
34579
+ _this._callOnScroll = void 0;
34580
+ _this._callOnScroll = memoizeOne(function (scrollLeft, scrollTop, horizontalScrollDirection, verticalScrollDirection, scrollUpdateWasRequested) {
34581
+ return _this.props.onScroll({
34582
+ horizontalScrollDirection: horizontalScrollDirection,
34583
+ scrollLeft: scrollLeft,
34584
+ scrollTop: scrollTop,
34585
+ verticalScrollDirection: verticalScrollDirection,
34586
+ scrollUpdateWasRequested: scrollUpdateWasRequested
34587
+ });
34588
+ });
34589
+ _this._getItemStyle = void 0;
34590
+
34591
+ _this._getItemStyle = function (rowIndex, columnIndex) {
34592
+ var _this$props = _this.props,
34593
+ columnWidth = _this$props.columnWidth,
34594
+ direction = _this$props.direction,
34595
+ rowHeight = _this$props.rowHeight;
34596
+
34597
+ var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && columnWidth, shouldResetStyleCacheOnItemSizeChange && direction, shouldResetStyleCacheOnItemSizeChange && rowHeight);
34598
+
34599
+ var key = rowIndex + ":" + columnIndex;
34600
+ var style;
34601
+
34602
+ if (itemStyleCache.hasOwnProperty(key)) {
34603
+ style = itemStyleCache[key];
34604
+ } else {
34605
+ var _offset = getColumnOffset(_this.props, columnIndex, _this._instanceProps);
34606
+
34607
+ var isRtl = direction === 'rtl';
34608
+ itemStyleCache[key] = style = {
34609
+ position: 'absolute',
34610
+ left: isRtl ? undefined : _offset,
34611
+ right: isRtl ? _offset : undefined,
34612
+ top: getRowOffset(_this.props, rowIndex, _this._instanceProps),
34613
+ height: getRowHeight(_this.props, rowIndex, _this._instanceProps),
34614
+ width: getColumnWidth(_this.props, columnIndex, _this._instanceProps)
34615
+ };
34616
+ }
34617
+
34618
+ return style;
34619
+ };
34620
+
34621
+ _this._getItemStyleCache = void 0;
34622
+ _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
34623
+ return {};
34624
+ });
34625
+
34626
+ _this._onScroll = function (event) {
34627
+ var _event$currentTarget = event.currentTarget,
34628
+ clientHeight = _event$currentTarget.clientHeight,
34629
+ clientWidth = _event$currentTarget.clientWidth,
34630
+ scrollLeft = _event$currentTarget.scrollLeft,
34631
+ scrollTop = _event$currentTarget.scrollTop,
34632
+ scrollHeight = _event$currentTarget.scrollHeight,
34633
+ scrollWidth = _event$currentTarget.scrollWidth;
34634
+
34635
+ _this.setState(function (prevState) {
34636
+ if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
34637
+ // Scroll position may have been updated by cDM/cDU,
34638
+ // In which case we don't need to trigger another render,
34639
+ // And we don't want to update state.isScrolling.
34640
+ return null;
34641
+ }
34642
+
34643
+ var direction = _this.props.direction; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
34644
+ // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
34645
+ // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
34646
+ // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
34647
+
34648
+ var calculatedScrollLeft = scrollLeft;
34649
+
34650
+ if (direction === 'rtl') {
34651
+ switch (getRTLOffsetType()) {
34652
+ case 'negative':
34653
+ calculatedScrollLeft = -scrollLeft;
34654
+ break;
34655
+
34656
+ case 'positive-descending':
34657
+ calculatedScrollLeft = scrollWidth - clientWidth - scrollLeft;
34658
+ break;
34659
+ }
34660
+ } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
34661
+
34662
+
34663
+ calculatedScrollLeft = Math.max(0, Math.min(calculatedScrollLeft, scrollWidth - clientWidth));
34664
+ var calculatedScrollTop = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
34665
+ return {
34666
+ isScrolling: true,
34667
+ horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
34668
+ scrollLeft: calculatedScrollLeft,
34669
+ scrollTop: calculatedScrollTop,
34670
+ verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward',
34671
+ scrollUpdateWasRequested: false
34672
+ };
34673
+ }, _this._resetIsScrollingDebounced);
34674
+ };
34675
+
34676
+ _this._outerRefSetter = function (ref) {
34677
+ var outerRef = _this.props.outerRef;
34678
+ _this._outerRef = ref;
34679
+
34680
+ if (typeof outerRef === 'function') {
34681
+ outerRef(ref);
34682
+ } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
34683
+ outerRef.current = ref;
34684
+ }
34685
+ };
34686
+
34687
+ _this._resetIsScrollingDebounced = function () {
34688
+ if (_this._resetIsScrollingTimeoutId !== null) {
34689
+ cancelTimeout(_this._resetIsScrollingTimeoutId);
34690
+ }
34691
+
34692
+ _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL);
34693
+ };
34694
+
34695
+ _this._resetIsScrolling = function () {
34696
+ _this._resetIsScrollingTimeoutId = null;
34697
+
34698
+ _this.setState({
34699
+ isScrolling: false
34700
+ }, function () {
34701
+ // Clear style cache after state update has been committed.
34702
+ // This way we don't break pure sCU for items that don't use isScrolling param.
34703
+ _this._getItemStyleCache(-1);
34704
+ });
34705
+ };
34706
+
34707
+ return _this;
34708
+ }
34709
+
34710
+ Grid.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
34711
+ validateSharedProps(nextProps, prevState);
34712
+ validateProps(nextProps);
34713
+ return null;
34714
+ };
34715
+
34716
+ var _proto = Grid.prototype;
34717
+
34718
+ _proto.scrollTo = function scrollTo(_ref3) {
34719
+ var scrollLeft = _ref3.scrollLeft,
34720
+ scrollTop = _ref3.scrollTop;
34721
+
34722
+ if (scrollLeft !== undefined) {
34723
+ scrollLeft = Math.max(0, scrollLeft);
34724
+ }
34725
+
34726
+ if (scrollTop !== undefined) {
34727
+ scrollTop = Math.max(0, scrollTop);
34728
+ }
34729
+
34730
+ this.setState(function (prevState) {
34731
+ if (scrollLeft === undefined) {
34732
+ scrollLeft = prevState.scrollLeft;
34733
+ }
34734
+
34735
+ if (scrollTop === undefined) {
34736
+ scrollTop = prevState.scrollTop;
34737
+ }
34738
+
34739
+ if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
34740
+ return null;
34741
+ }
34742
+
34743
+ return {
34744
+ horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
34745
+ scrollLeft: scrollLeft,
34746
+ scrollTop: scrollTop,
34747
+ scrollUpdateWasRequested: true,
34748
+ verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward'
34749
+ };
34750
+ }, this._resetIsScrollingDebounced);
34751
+ };
34752
+
34753
+ _proto.scrollToItem = function scrollToItem(_ref4) {
34754
+ var _ref4$align = _ref4.align,
34755
+ align = _ref4$align === void 0 ? 'auto' : _ref4$align,
34756
+ columnIndex = _ref4.columnIndex,
34757
+ rowIndex = _ref4.rowIndex;
34758
+ var _this$props2 = this.props,
34759
+ columnCount = _this$props2.columnCount,
34760
+ height = _this$props2.height,
34761
+ rowCount = _this$props2.rowCount,
34762
+ width = _this$props2.width;
34763
+ var _this$state = this.state,
34764
+ scrollLeft = _this$state.scrollLeft,
34765
+ scrollTop = _this$state.scrollTop;
34766
+ var scrollbarSize = getScrollbarSize();
34767
+
34768
+ if (columnIndex !== undefined) {
34769
+ columnIndex = Math.max(0, Math.min(columnIndex, columnCount - 1));
34770
+ }
34771
+
34772
+ if (rowIndex !== undefined) {
34773
+ rowIndex = Math.max(0, Math.min(rowIndex, rowCount - 1));
34774
+ }
34775
+
34776
+ var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
34777
+ var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps); // The scrollbar size should be considered when scrolling an item into view,
34778
+ // to ensure it's fully visible.
34779
+ // But we only need to account for its size when it's actually visible.
34780
+
34781
+ var horizontalScrollbarSize = estimatedTotalWidth > width ? scrollbarSize : 0;
34782
+ var verticalScrollbarSize = estimatedTotalHeight > height ? scrollbarSize : 0;
34783
+ this.scrollTo({
34784
+ scrollLeft: columnIndex !== undefined ? getOffsetForColumnAndAlignment(this.props, columnIndex, align, scrollLeft, this._instanceProps, verticalScrollbarSize) : scrollLeft,
34785
+ scrollTop: rowIndex !== undefined ? getOffsetForRowAndAlignment(this.props, rowIndex, align, scrollTop, this._instanceProps, horizontalScrollbarSize) : scrollTop
34786
+ });
34787
+ };
34788
+
34789
+ _proto.componentDidMount = function componentDidMount() {
34790
+ var _this$props3 = this.props,
34791
+ initialScrollLeft = _this$props3.initialScrollLeft,
34792
+ initialScrollTop = _this$props3.initialScrollTop;
34793
+
34794
+ if (this._outerRef != null) {
34795
+ var outerRef = this._outerRef;
34796
+
34797
+ if (typeof initialScrollLeft === 'number') {
34798
+ outerRef.scrollLeft = initialScrollLeft;
34799
+ }
34800
+
34801
+ if (typeof initialScrollTop === 'number') {
34802
+ outerRef.scrollTop = initialScrollTop;
34803
+ }
34804
+ }
34805
+
34806
+ this._callPropsCallbacks();
34807
+ };
34808
+
34809
+ _proto.componentDidUpdate = function componentDidUpdate() {
34810
+ var direction = this.props.direction;
34811
+ var _this$state2 = this.state,
34812
+ scrollLeft = _this$state2.scrollLeft,
34813
+ scrollTop = _this$state2.scrollTop,
34814
+ scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
34815
+
34816
+ if (scrollUpdateWasRequested && this._outerRef != null) {
34817
+ // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
34818
+ // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
34819
+ // So we need to determine which browser behavior we're dealing with, and mimic it.
34820
+ var outerRef = this._outerRef;
34821
+
34822
+ if (direction === 'rtl') {
34823
+ switch (getRTLOffsetType()) {
34824
+ case 'negative':
34825
+ outerRef.scrollLeft = -scrollLeft;
34826
+ break;
34827
+
34828
+ case 'positive-ascending':
34829
+ outerRef.scrollLeft = scrollLeft;
34830
+ break;
34831
+
34832
+ default:
34833
+ var clientWidth = outerRef.clientWidth,
34834
+ scrollWidth = outerRef.scrollWidth;
34835
+ outerRef.scrollLeft = scrollWidth - clientWidth - scrollLeft;
34836
+ break;
34837
+ }
34838
+ } else {
34839
+ outerRef.scrollLeft = Math.max(0, scrollLeft);
34840
+ }
34841
+
34842
+ outerRef.scrollTop = Math.max(0, scrollTop);
34843
+ }
34844
+
34845
+ this._callPropsCallbacks();
34846
+ };
34847
+
34848
+ _proto.componentWillUnmount = function componentWillUnmount() {
34849
+ if (this._resetIsScrollingTimeoutId !== null) {
34850
+ cancelTimeout(this._resetIsScrollingTimeoutId);
34851
+ }
34852
+ };
34853
+
34854
+ _proto.render = function render() {
34855
+ var _this$props4 = this.props,
34856
+ children = _this$props4.children,
34857
+ className = _this$props4.className,
34858
+ columnCount = _this$props4.columnCount,
34859
+ direction = _this$props4.direction,
34860
+ height = _this$props4.height,
34861
+ innerRef = _this$props4.innerRef,
34862
+ innerElementType = _this$props4.innerElementType,
34863
+ innerTagName = _this$props4.innerTagName,
34864
+ itemData = _this$props4.itemData,
34865
+ _this$props4$itemKey = _this$props4.itemKey,
34866
+ itemKey = _this$props4$itemKey === void 0 ? defaultItemKey : _this$props4$itemKey,
34867
+ outerElementType = _this$props4.outerElementType,
34868
+ outerTagName = _this$props4.outerTagName,
34869
+ rowCount = _this$props4.rowCount,
34870
+ style = _this$props4.style,
34871
+ useIsScrolling = _this$props4.useIsScrolling,
34872
+ width = _this$props4.width;
34873
+ var isScrolling = this.state.isScrolling;
34874
+
34875
+ var _this$_getHorizontalR = this._getHorizontalRangeToRender(),
34876
+ columnStartIndex = _this$_getHorizontalR[0],
34877
+ columnStopIndex = _this$_getHorizontalR[1];
34878
+
34879
+ var _this$_getVerticalRan = this._getVerticalRangeToRender(),
34880
+ rowStartIndex = _this$_getVerticalRan[0],
34881
+ rowStopIndex = _this$_getVerticalRan[1];
34882
+
34883
+ var items = [];
34884
+
34885
+ if (columnCount > 0 && rowCount) {
34886
+ for (var _rowIndex = rowStartIndex; _rowIndex <= rowStopIndex; _rowIndex++) {
34887
+ for (var _columnIndex = columnStartIndex; _columnIndex <= columnStopIndex; _columnIndex++) {
34888
+ items.push(createElement(children, {
34889
+ columnIndex: _columnIndex,
34890
+ data: itemData,
34891
+ isScrolling: useIsScrolling ? isScrolling : undefined,
34892
+ key: itemKey({
34893
+ columnIndex: _columnIndex,
34894
+ data: itemData,
34895
+ rowIndex: _rowIndex
34896
+ }),
34897
+ rowIndex: _rowIndex,
34898
+ style: this._getItemStyle(_rowIndex, _columnIndex)
34899
+ }));
34900
+ }
34901
+ }
34902
+ } // Read this value AFTER items have been created,
34903
+ // So their actual sizes (if variable) are taken into consideration.
34904
+
34905
+
34906
+ var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
34907
+ var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps);
34908
+ return createElement(outerElementType || outerTagName || 'div', {
34909
+ className: className,
34910
+ onScroll: this._onScroll,
34911
+ ref: this._outerRefSetter,
34912
+ style: _extends({
34913
+ position: 'relative',
34914
+ height: height,
34915
+ width: width,
34916
+ overflow: 'auto',
34917
+ WebkitOverflowScrolling: 'touch',
34918
+ willChange: 'transform',
34919
+ direction: direction
34920
+ }, style)
34921
+ }, createElement(innerElementType || innerTagName || 'div', {
34922
+ children: items,
34923
+ ref: innerRef,
34924
+ style: {
34925
+ height: estimatedTotalHeight,
34926
+ pointerEvents: isScrolling ? 'none' : undefined,
34927
+ width: estimatedTotalWidth
34928
+ }
34929
+ }));
34930
+ };
34931
+
34932
+ _proto._callPropsCallbacks = function _callPropsCallbacks() {
34933
+ var _this$props5 = this.props,
34934
+ columnCount = _this$props5.columnCount,
34935
+ onItemsRendered = _this$props5.onItemsRendered,
34936
+ onScroll = _this$props5.onScroll,
34937
+ rowCount = _this$props5.rowCount;
34938
+
34939
+ if (typeof onItemsRendered === 'function') {
34940
+ if (columnCount > 0 && rowCount > 0) {
34941
+ var _this$_getHorizontalR2 = this._getHorizontalRangeToRender(),
34942
+ _overscanColumnStartIndex = _this$_getHorizontalR2[0],
34943
+ _overscanColumnStopIndex = _this$_getHorizontalR2[1],
34944
+ _visibleColumnStartIndex = _this$_getHorizontalR2[2],
34945
+ _visibleColumnStopIndex = _this$_getHorizontalR2[3];
34946
+
34947
+ var _this$_getVerticalRan2 = this._getVerticalRangeToRender(),
34948
+ _overscanRowStartIndex = _this$_getVerticalRan2[0],
34949
+ _overscanRowStopIndex = _this$_getVerticalRan2[1],
34950
+ _visibleRowStartIndex = _this$_getVerticalRan2[2],
34951
+ _visibleRowStopIndex = _this$_getVerticalRan2[3];
34952
+
34953
+ this._callOnItemsRendered(_overscanColumnStartIndex, _overscanColumnStopIndex, _overscanRowStartIndex, _overscanRowStopIndex, _visibleColumnStartIndex, _visibleColumnStopIndex, _visibleRowStartIndex, _visibleRowStopIndex);
34954
+ }
34955
+ }
34956
+
34957
+ if (typeof onScroll === 'function') {
34958
+ var _this$state3 = this.state,
34959
+ _horizontalScrollDirection = _this$state3.horizontalScrollDirection,
34960
+ _scrollLeft = _this$state3.scrollLeft,
34961
+ _scrollTop = _this$state3.scrollTop,
34962
+ _scrollUpdateWasRequested = _this$state3.scrollUpdateWasRequested,
34963
+ _verticalScrollDirection = _this$state3.verticalScrollDirection;
34964
+
34965
+ this._callOnScroll(_scrollLeft, _scrollTop, _horizontalScrollDirection, _verticalScrollDirection, _scrollUpdateWasRequested);
34966
+ }
34967
+ } // Lazily create and cache item styles while scrolling,
34968
+ // So that pure component sCU will prevent re-renders.
34969
+ // We maintain this cache, and pass a style prop rather than index,
34970
+ // So that List can clear cached styles and force item re-render if necessary.
34971
+ ;
34972
+
34973
+ _proto._getHorizontalRangeToRender = function _getHorizontalRangeToRender() {
34974
+ var _this$props6 = this.props,
34975
+ columnCount = _this$props6.columnCount,
34976
+ overscanColumnCount = _this$props6.overscanColumnCount,
34977
+ overscanColumnsCount = _this$props6.overscanColumnsCount,
34978
+ overscanCount = _this$props6.overscanCount,
34979
+ rowCount = _this$props6.rowCount;
34980
+ var _this$state4 = this.state,
34981
+ horizontalScrollDirection = _this$state4.horizontalScrollDirection,
34982
+ isScrolling = _this$state4.isScrolling,
34983
+ scrollLeft = _this$state4.scrollLeft;
34984
+ var overscanCountResolved = overscanColumnCount || overscanColumnsCount || overscanCount || 1;
34985
+
34986
+ if (columnCount === 0 || rowCount === 0) {
34987
+ return [0, 0, 0, 0];
34988
+ }
34989
+
34990
+ var startIndex = getColumnStartIndexForOffset(this.props, scrollLeft, this._instanceProps);
34991
+ var stopIndex = getColumnStopIndexForStartIndex(this.props, startIndex, scrollLeft, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
34992
+ // If there isn't at least one extra item, tab loops back around.
34993
+
34994
+ var overscanBackward = !isScrolling || horizontalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
34995
+ var overscanForward = !isScrolling || horizontalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
34996
+ return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(columnCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
34997
+ };
34998
+
34999
+ _proto._getVerticalRangeToRender = function _getVerticalRangeToRender() {
35000
+ var _this$props7 = this.props,
35001
+ columnCount = _this$props7.columnCount,
35002
+ overscanCount = _this$props7.overscanCount,
35003
+ overscanRowCount = _this$props7.overscanRowCount,
35004
+ overscanRowsCount = _this$props7.overscanRowsCount,
35005
+ rowCount = _this$props7.rowCount;
35006
+ var _this$state5 = this.state,
35007
+ isScrolling = _this$state5.isScrolling,
35008
+ verticalScrollDirection = _this$state5.verticalScrollDirection,
35009
+ scrollTop = _this$state5.scrollTop;
35010
+ var overscanCountResolved = overscanRowCount || overscanRowsCount || overscanCount || 1;
35011
+
35012
+ if (columnCount === 0 || rowCount === 0) {
35013
+ return [0, 0, 0, 0];
35014
+ }
35015
+
35016
+ var startIndex = getRowStartIndexForOffset(this.props, scrollTop, this._instanceProps);
35017
+ var stopIndex = getRowStopIndexForStartIndex(this.props, startIndex, scrollTop, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
35018
+ // If there isn't at least one extra item, tab loops back around.
35019
+
35020
+ var overscanBackward = !isScrolling || verticalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
35021
+ var overscanForward = !isScrolling || verticalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
35022
+ return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(rowCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
35023
+ };
35024
+
35025
+ return Grid;
35026
+ }(PureComponent), _class.defaultProps = {
35027
+ direction: 'ltr',
35028
+ itemData: undefined,
35029
+ useIsScrolling: false
35030
+ }, _class;
35031
+ }
35032
+
35033
+ var validateSharedProps = function validateSharedProps(_ref5, _ref6) {
35034
+ var children = _ref5.children,
35035
+ direction = _ref5.direction,
35036
+ height = _ref5.height,
35037
+ innerTagName = _ref5.innerTagName,
35038
+ outerTagName = _ref5.outerTagName,
35039
+ overscanColumnsCount = _ref5.overscanColumnsCount,
35040
+ overscanCount = _ref5.overscanCount,
35041
+ overscanRowsCount = _ref5.overscanRowsCount,
35042
+ width = _ref5.width;
35043
+ var instance = _ref6.instance;
35044
+
35045
+ if (process.env.NODE_ENV !== 'production') {
35046
+ if (typeof overscanCount === 'number') {
35047
+ if (devWarningsOverscanCount && !devWarningsOverscanCount.has(instance)) {
35048
+ devWarningsOverscanCount.add(instance);
35049
+ console.warn('The overscanCount prop has been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
35050
+ }
35051
+ }
35052
+
35053
+ if (typeof overscanColumnsCount === 'number' || typeof overscanRowsCount === 'number') {
35054
+ if (devWarningsOverscanRowsColumnsCount && !devWarningsOverscanRowsColumnsCount.has(instance)) {
35055
+ devWarningsOverscanRowsColumnsCount.add(instance);
35056
+ console.warn('The overscanColumnsCount and overscanRowsCount props have been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
35057
+ }
35058
+ }
35059
+
35060
+ if (innerTagName != null || outerTagName != null) {
35061
+ if (devWarningsTagName && !devWarningsTagName.has(instance)) {
35062
+ devWarningsTagName.add(instance);
35063
+ console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
35064
+ }
35065
+ }
35066
+
35067
+ if (children == null) {
35068
+ throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
35069
+ }
35070
+
35071
+ switch (direction) {
35072
+ case 'ltr':
35073
+ case 'rtl':
35074
+ // Valid values
35075
+ break;
35076
+
35077
+ default:
35078
+ throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
35079
+ }
35080
+
35081
+ if (typeof width !== 'number') {
35082
+ throw Error('An invalid "width" prop has been specified. ' + 'Grids must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
35083
+ }
35084
+
35085
+ if (typeof height !== 'number') {
35086
+ throw Error('An invalid "height" prop has been specified. ' + 'Grids must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
35087
+ }
35088
+ }
35089
+ };
35090
+
35091
+ var DEFAULT_ESTIMATED_ITEM_SIZE = 50;
35092
+
35093
+ var getEstimatedTotalHeight = function getEstimatedTotalHeight(_ref, _ref2) {
35094
+ var rowCount = _ref.rowCount;
35095
+ var rowMetadataMap = _ref2.rowMetadataMap,
35096
+ estimatedRowHeight = _ref2.estimatedRowHeight,
35097
+ lastMeasuredRowIndex = _ref2.lastMeasuredRowIndex;
35098
+ var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
35099
+ // https://github.com/bvaughn/react-window/pull/138
35100
+
35101
+ if (lastMeasuredRowIndex >= rowCount) {
35102
+ lastMeasuredRowIndex = rowCount - 1;
35103
+ }
35104
+
35105
+ if (lastMeasuredRowIndex >= 0) {
35106
+ var itemMetadata = rowMetadataMap[lastMeasuredRowIndex];
35107
+ totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
35108
+ }
35109
+
35110
+ var numUnmeasuredItems = rowCount - lastMeasuredRowIndex - 1;
35111
+ var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedRowHeight;
35112
+ return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
35113
+ };
35114
+
35115
+ var getEstimatedTotalWidth = function getEstimatedTotalWidth(_ref3, _ref4) {
35116
+ var columnCount = _ref3.columnCount;
35117
+ var columnMetadataMap = _ref4.columnMetadataMap,
35118
+ estimatedColumnWidth = _ref4.estimatedColumnWidth,
35119
+ lastMeasuredColumnIndex = _ref4.lastMeasuredColumnIndex;
35120
+ var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
35121
+ // https://github.com/bvaughn/react-window/pull/138
35122
+
35123
+ if (lastMeasuredColumnIndex >= columnCount) {
35124
+ lastMeasuredColumnIndex = columnCount - 1;
35125
+ }
35126
+
35127
+ if (lastMeasuredColumnIndex >= 0) {
35128
+ var itemMetadata = columnMetadataMap[lastMeasuredColumnIndex];
35129
+ totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
35130
+ }
35131
+
35132
+ var numUnmeasuredItems = columnCount - lastMeasuredColumnIndex - 1;
35133
+ var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedColumnWidth;
35134
+ return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
35135
+ };
35136
+
35137
+ var getItemMetadata = function getItemMetadata(itemType, props, index, instanceProps) {
35138
+ var itemMetadataMap, itemSize, lastMeasuredIndex;
35139
+
35140
+ if (itemType === 'column') {
35141
+ itemMetadataMap = instanceProps.columnMetadataMap;
35142
+ itemSize = props.columnWidth;
35143
+ lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
35144
+ } else {
35145
+ itemMetadataMap = instanceProps.rowMetadataMap;
35146
+ itemSize = props.rowHeight;
35147
+ lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
35148
+ }
35149
+
35150
+ if (index > lastMeasuredIndex) {
35151
+ var offset = 0;
35152
+
35153
+ if (lastMeasuredIndex >= 0) {
35154
+ var itemMetadata = itemMetadataMap[lastMeasuredIndex];
35155
+ offset = itemMetadata.offset + itemMetadata.size;
35156
+ }
35157
+
35158
+ for (var i = lastMeasuredIndex + 1; i <= index; i++) {
35159
+ var size = itemSize(i);
35160
+ itemMetadataMap[i] = {
35161
+ offset: offset,
35162
+ size: size
35163
+ };
35164
+ offset += size;
35165
+ }
35166
+
35167
+ if (itemType === 'column') {
35168
+ instanceProps.lastMeasuredColumnIndex = index;
35169
+ } else {
35170
+ instanceProps.lastMeasuredRowIndex = index;
35171
+ }
35172
+ }
35173
+
35174
+ return itemMetadataMap[index];
35175
+ };
35176
+
35177
+ var findNearestItem = function findNearestItem(itemType, props, instanceProps, offset) {
35178
+ var itemMetadataMap, lastMeasuredIndex;
35179
+
35180
+ if (itemType === 'column') {
35181
+ itemMetadataMap = instanceProps.columnMetadataMap;
35182
+ lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
35183
+ } else {
35184
+ itemMetadataMap = instanceProps.rowMetadataMap;
35185
+ lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
35186
+ }
35187
+
35188
+ var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
35189
+
35190
+ if (lastMeasuredItemOffset >= offset) {
35191
+ // If we've already measured items within this range just use a binary search as it's faster.
35192
+ return findNearestItemBinarySearch(itemType, props, instanceProps, lastMeasuredIndex, 0, offset);
35193
+ } else {
35194
+ // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
35195
+ // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
35196
+ // The overall complexity for this approach is O(log n).
35197
+ return findNearestItemExponentialSearch(itemType, props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
35198
+ }
35199
+ };
35200
+
35201
+ var findNearestItemBinarySearch = function findNearestItemBinarySearch(itemType, props, instanceProps, high, low, offset) {
35202
+ while (low <= high) {
35203
+ var middle = low + Math.floor((high - low) / 2);
35204
+ var currentOffset = getItemMetadata(itemType, props, middle, instanceProps).offset;
35205
+
35206
+ if (currentOffset === offset) {
35207
+ return middle;
35208
+ } else if (currentOffset < offset) {
35209
+ low = middle + 1;
35210
+ } else if (currentOffset > offset) {
35211
+ high = middle - 1;
35212
+ }
35213
+ }
35214
+
35215
+ if (low > 0) {
35216
+ return low - 1;
35217
+ } else {
35218
+ return 0;
35219
+ }
35220
+ };
35221
+
35222
+ var findNearestItemExponentialSearch = function findNearestItemExponentialSearch(itemType, props, instanceProps, index, offset) {
35223
+ var itemCount = itemType === 'column' ? props.columnCount : props.rowCount;
35224
+ var interval = 1;
35225
+
35226
+ while (index < itemCount && getItemMetadata(itemType, props, index, instanceProps).offset < offset) {
35227
+ index += interval;
35228
+ interval *= 2;
35229
+ }
35230
+
35231
+ return findNearestItemBinarySearch(itemType, props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
35232
+ };
35233
+
35234
+ var getOffsetForIndexAndAlignment = function getOffsetForIndexAndAlignment(itemType, props, index, align, scrollOffset, instanceProps, scrollbarSize) {
35235
+ var size = itemType === 'column' ? props.width : props.height;
35236
+ var itemMetadata = getItemMetadata(itemType, props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
35237
+ // To ensure it reflects actual measurements instead of just estimates.
35238
+
35239
+ var estimatedTotalSize = itemType === 'column' ? getEstimatedTotalWidth(props, instanceProps) : getEstimatedTotalHeight(props, instanceProps);
35240
+ var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
35241
+ var minOffset = Math.max(0, itemMetadata.offset - size + scrollbarSize + itemMetadata.size);
35242
+
35243
+ if (align === 'smart') {
35244
+ if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
35245
+ align = 'auto';
35246
+ } else {
35247
+ align = 'center';
35248
+ }
35249
+ }
35250
+
35251
+ switch (align) {
35252
+ case 'start':
35253
+ return maxOffset;
35254
+
35255
+ case 'end':
35256
+ return minOffset;
35257
+
35258
+ case 'center':
35259
+ return Math.round(minOffset + (maxOffset - minOffset) / 2);
35260
+
35261
+ case 'auto':
35262
+ default:
35263
+ if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
35264
+ return scrollOffset;
35265
+ } else if (minOffset > maxOffset) {
35266
+ // Because we only take into account the scrollbar size when calculating minOffset
35267
+ // this value can be larger than maxOffset when at the end of the list
35268
+ return minOffset;
35269
+ } else if (scrollOffset < minOffset) {
35270
+ return minOffset;
35271
+ } else {
35272
+ return maxOffset;
35273
+ }
35274
+
35275
+ }
35276
+ };
35277
+
35278
+ var VariableSizeGrid = /*#__PURE__*/createGridComponent({
35279
+ getColumnOffset: function getColumnOffset(props, index, instanceProps) {
35280
+ return getItemMetadata('column', props, index, instanceProps).offset;
35281
+ },
35282
+ getColumnStartIndexForOffset: function getColumnStartIndexForOffset(props, scrollLeft, instanceProps) {
35283
+ return findNearestItem('column', props, instanceProps, scrollLeft);
35284
+ },
35285
+ getColumnStopIndexForStartIndex: function getColumnStopIndexForStartIndex(props, startIndex, scrollLeft, instanceProps) {
35286
+ var columnCount = props.columnCount,
35287
+ width = props.width;
35288
+ var itemMetadata = getItemMetadata('column', props, startIndex, instanceProps);
35289
+ var maxOffset = scrollLeft + width;
35290
+ var offset = itemMetadata.offset + itemMetadata.size;
35291
+ var stopIndex = startIndex;
35292
+
35293
+ while (stopIndex < columnCount - 1 && offset < maxOffset) {
35294
+ stopIndex++;
35295
+ offset += getItemMetadata('column', props, stopIndex, instanceProps).size;
35296
+ }
35297
+
35298
+ return stopIndex;
35299
+ },
35300
+ getColumnWidth: function getColumnWidth(props, index, instanceProps) {
35301
+ return instanceProps.columnMetadataMap[index].size;
35302
+ },
35303
+ getEstimatedTotalHeight: getEstimatedTotalHeight,
35304
+ getEstimatedTotalWidth: getEstimatedTotalWidth,
35305
+ getOffsetForColumnAndAlignment: function getOffsetForColumnAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
35306
+ return getOffsetForIndexAndAlignment('column', props, index, align, scrollOffset, instanceProps, scrollbarSize);
35307
+ },
35308
+ getOffsetForRowAndAlignment: function getOffsetForRowAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
35309
+ return getOffsetForIndexAndAlignment('row', props, index, align, scrollOffset, instanceProps, scrollbarSize);
35310
+ },
35311
+ getRowOffset: function getRowOffset(props, index, instanceProps) {
35312
+ return getItemMetadata('row', props, index, instanceProps).offset;
35313
+ },
35314
+ getRowHeight: function getRowHeight(props, index, instanceProps) {
35315
+ return instanceProps.rowMetadataMap[index].size;
35316
+ },
35317
+ getRowStartIndexForOffset: function getRowStartIndexForOffset(props, scrollTop, instanceProps) {
35318
+ return findNearestItem('row', props, instanceProps, scrollTop);
35319
+ },
35320
+ getRowStopIndexForStartIndex: function getRowStopIndexForStartIndex(props, startIndex, scrollTop, instanceProps) {
35321
+ var rowCount = props.rowCount,
35322
+ height = props.height;
35323
+ var itemMetadata = getItemMetadata('row', props, startIndex, instanceProps);
35324
+ var maxOffset = scrollTop + height;
35325
+ var offset = itemMetadata.offset + itemMetadata.size;
35326
+ var stopIndex = startIndex;
35327
+
35328
+ while (stopIndex < rowCount - 1 && offset < maxOffset) {
35329
+ stopIndex++;
35330
+ offset += getItemMetadata('row', props, stopIndex, instanceProps).size;
35331
+ }
35332
+
35333
+ return stopIndex;
35334
+ },
35335
+ initInstanceProps: function initInstanceProps(props, instance) {
35336
+ var _ref5 = props,
35337
+ estimatedColumnWidth = _ref5.estimatedColumnWidth,
35338
+ estimatedRowHeight = _ref5.estimatedRowHeight;
35339
+ var instanceProps = {
35340
+ columnMetadataMap: {},
35341
+ estimatedColumnWidth: estimatedColumnWidth || DEFAULT_ESTIMATED_ITEM_SIZE,
35342
+ estimatedRowHeight: estimatedRowHeight || DEFAULT_ESTIMATED_ITEM_SIZE,
35343
+ lastMeasuredColumnIndex: -1,
35344
+ lastMeasuredRowIndex: -1,
35345
+ rowMetadataMap: {}
35346
+ };
35347
+
35348
+ instance.resetAfterColumnIndex = function (columnIndex, shouldForceUpdate) {
35349
+ if (shouldForceUpdate === void 0) {
35350
+ shouldForceUpdate = true;
35351
+ }
35352
+
35353
+ instance.resetAfterIndices({
35354
+ columnIndex: columnIndex,
35355
+ shouldForceUpdate: shouldForceUpdate
35356
+ });
35357
+ };
35358
+
35359
+ instance.resetAfterRowIndex = function (rowIndex, shouldForceUpdate) {
35360
+ if (shouldForceUpdate === void 0) {
35361
+ shouldForceUpdate = true;
35362
+ }
35363
+
35364
+ instance.resetAfterIndices({
35365
+ rowIndex: rowIndex,
35366
+ shouldForceUpdate: shouldForceUpdate
35367
+ });
35368
+ };
35369
+
35370
+ instance.resetAfterIndices = function (_ref6) {
35371
+ var columnIndex = _ref6.columnIndex,
35372
+ rowIndex = _ref6.rowIndex,
35373
+ _ref6$shouldForceUpda = _ref6.shouldForceUpdate,
35374
+ shouldForceUpdate = _ref6$shouldForceUpda === void 0 ? true : _ref6$shouldForceUpda;
35375
+
35376
+ if (typeof columnIndex === 'number') {
35377
+ instanceProps.lastMeasuredColumnIndex = Math.min(instanceProps.lastMeasuredColumnIndex, columnIndex - 1);
35378
+ }
35379
+
35380
+ if (typeof rowIndex === 'number') {
35381
+ instanceProps.lastMeasuredRowIndex = Math.min(instanceProps.lastMeasuredRowIndex, rowIndex - 1);
35382
+ } // We could potentially optimize further by only evicting styles after this index,
35383
+ // But since styles are only cached while scrolling is in progress-
35384
+ // It seems an unnecessary optimization.
35385
+ // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
35386
+
35387
+
35388
+ instance._getItemStyleCache(-1);
35389
+
35390
+ if (shouldForceUpdate) {
35391
+ instance.forceUpdate();
35392
+ }
35393
+ };
35394
+
35395
+ return instanceProps;
35396
+ },
35397
+ shouldResetStyleCacheOnItemSizeChange: false,
35398
+ validateProps: function validateProps(_ref7) {
35399
+ var columnWidth = _ref7.columnWidth,
35400
+ rowHeight = _ref7.rowHeight;
35401
+
35402
+ if (process.env.NODE_ENV !== 'production') {
35403
+ if (typeof columnWidth !== 'function') {
35404
+ throw Error('An invalid "columnWidth" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (columnWidth === null ? 'null' : typeof columnWidth) + "\" was specified."));
35405
+ } else if (typeof rowHeight !== 'function') {
35406
+ throw Error('An invalid "rowHeight" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (rowHeight === null ? 'null' : typeof rowHeight) + "\" was specified."));
35407
+ }
35408
+ }
35409
+ }
35410
+ });
35411
+
35412
+ if (process.env.NODE_ENV !== 'production') ;
35413
+
35414
+ /**
35415
+ * Detect Element Resize.
35416
+ * https://github.com/sdecima/javascript-detect-element-resize
35417
+ * Sebastian Decima
35418
+ *
35419
+ * Forked from version 0.5.3; includes the following modifications:
35420
+ * 1) Guard against unsafe 'window' and 'document' references (to support SSR).
35421
+ * 2) Defer initialization code via a top-level function wrapper (to support SSR).
35422
+ * 3) Avoid unnecessary reflows by not measuring size for scroll events bubbling from children.
35423
+ * 4) Add nonce for style element.
35424
+ * 5) Use 'export' statement over 'module.exports' assignment
35425
+ **/
35426
+
35427
+ // Check `document` and `window` in case of server-side rendering
35428
+ let windowObject;
35429
+ if (typeof window !== "undefined") {
35430
+ windowObject = window;
35431
+
35432
+ // eslint-disable-next-line no-restricted-globals
35433
+ } else if (typeof self !== "undefined") {
35434
+ // eslint-disable-next-line no-restricted-globals
35435
+ windowObject = self;
35436
+ } else {
35437
+ windowObject = global;
35438
+ }
35439
+ let cancelFrame = null;
35440
+ let requestFrame = null;
35441
+ const TIMEOUT_DURATION = 20;
35442
+ const clearTimeoutFn = windowObject.clearTimeout;
35443
+ const setTimeoutFn = windowObject.setTimeout;
35444
+ const cancelAnimationFrameFn = windowObject.cancelAnimationFrame || windowObject.mozCancelAnimationFrame || windowObject.webkitCancelAnimationFrame;
35445
+ const requestAnimationFrameFn = windowObject.requestAnimationFrame || windowObject.mozRequestAnimationFrame || windowObject.webkitRequestAnimationFrame;
35446
+ if (cancelAnimationFrameFn == null || requestAnimationFrameFn == null) {
35447
+ // For environments that don't support animation frame,
35448
+ // fallback to a setTimeout based approach.
35449
+ cancelFrame = clearTimeoutFn;
35450
+ requestFrame = function requestAnimationFrameViaSetTimeout(callback) {
35451
+ return setTimeoutFn(callback, TIMEOUT_DURATION);
35452
+ };
35453
+ } else {
35454
+ // Counter intuitively, environments that support animation frames can be trickier.
35455
+ // Chrome's "Throttle non-visible cross-origin iframes" flag can prevent rAFs from being called.
35456
+ // In this case, we should fallback to a setTimeout() implementation.
35457
+ cancelFrame = function cancelFrame([animationFrameID, timeoutID]) {
35458
+ cancelAnimationFrameFn(animationFrameID);
35459
+ clearTimeoutFn(timeoutID);
35460
+ };
35461
+ requestFrame = function requestAnimationFrameWithSetTimeoutFallback(callback) {
35462
+ const animationFrameID = requestAnimationFrameFn(function animationFrameCallback() {
35463
+ clearTimeoutFn(timeoutID);
35464
+ callback();
35465
+ });
35466
+ const timeoutID = setTimeoutFn(function timeoutCallback() {
35467
+ cancelAnimationFrameFn(animationFrameID);
35468
+ callback();
35469
+ }, TIMEOUT_DURATION);
35470
+ return [animationFrameID, timeoutID];
35471
+ };
35472
+ }
35473
+ function createDetectElementResize(nonce) {
35474
+ let animationKeyframes;
35475
+ let animationName;
35476
+ let animationStartEvent;
35477
+ let animationStyle;
35478
+ let checkTriggers;
35479
+ let resetTriggers;
35480
+ let scrollListener;
35481
+ const attachEvent = typeof document !== "undefined" && document.attachEvent;
35482
+ if (!attachEvent) {
35483
+ resetTriggers = function (element) {
35484
+ const triggers = element.__resizeTriggers__,
35485
+ expand = triggers.firstElementChild,
35486
+ contract = triggers.lastElementChild,
35487
+ expandChild = expand.firstElementChild;
35488
+ contract.scrollLeft = contract.scrollWidth;
35489
+ contract.scrollTop = contract.scrollHeight;
35490
+ expandChild.style.width = expand.offsetWidth + 1 + "px";
35491
+ expandChild.style.height = expand.offsetHeight + 1 + "px";
35492
+ expand.scrollLeft = expand.scrollWidth;
35493
+ expand.scrollTop = expand.scrollHeight;
35494
+ };
35495
+ checkTriggers = function (element) {
35496
+ return element.offsetWidth !== element.__resizeLast__.width || element.offsetHeight !== element.__resizeLast__.height;
35497
+ };
35498
+ scrollListener = function (e) {
35499
+ // Don't measure (which forces) reflow for scrolls that happen inside of children!
35500
+ if (e.target.className && typeof e.target.className.indexOf === "function" && e.target.className.indexOf("contract-trigger") < 0 && e.target.className.indexOf("expand-trigger") < 0) {
35501
+ return;
35502
+ }
35503
+ const element = this;
35504
+ resetTriggers(this);
35505
+ if (this.__resizeRAF__) {
35506
+ cancelFrame(this.__resizeRAF__);
35507
+ }
35508
+ this.__resizeRAF__ = requestFrame(function animationFrame() {
35509
+ if (checkTriggers(element)) {
35510
+ element.__resizeLast__.width = element.offsetWidth;
35511
+ element.__resizeLast__.height = element.offsetHeight;
35512
+ element.__resizeListeners__.forEach(function forEachResizeListener(fn) {
35513
+ fn.call(element, e);
35514
+ });
35515
+ }
35516
+ });
35517
+ };
35518
+
35519
+ /* Detect CSS Animations support to detect element display/re-attach */
35520
+ let animation = false;
35521
+ let keyframeprefix = "";
35522
+ animationStartEvent = "animationstart";
35523
+ const domPrefixes = "Webkit Moz O ms".split(" ");
35524
+ let startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" ");
35525
+ let pfx = "";
35526
+ {
35527
+ const elm = document.createElement("fakeelement");
35528
+ if (elm.style.animationName !== undefined) {
35529
+ animation = true;
35530
+ }
35531
+ if (animation === false) {
35532
+ for (let i = 0; i < domPrefixes.length; i++) {
35533
+ if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) {
35534
+ pfx = domPrefixes[i];
35535
+ keyframeprefix = "-" + pfx.toLowerCase() + "-";
35536
+ animationStartEvent = startEvents[i];
35537
+ animation = true;
35538
+ break;
35539
+ }
35540
+ }
35541
+ }
35542
+ }
35543
+ animationName = "resizeanim";
35544
+ animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } ";
35545
+ animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; ";
35546
+ }
35547
+ const createStyles = function (doc) {
35548
+ if (!doc.getElementById("detectElementResize")) {
35549
+ //opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
35550
+ const css = (animationKeyframes ? animationKeyframes : "") + ".resize-triggers { " + (animationStyle ? animationStyle : "") + "visibility: hidden; opacity: 0; } " + '.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',
35551
+ head = doc.head || doc.getElementsByTagName("head")[0],
35552
+ style = doc.createElement("style");
35553
+ style.id = "detectElementResize";
35554
+ style.type = "text/css";
35555
+ if (nonce != null) {
35556
+ style.setAttribute("nonce", nonce);
35557
+ }
35558
+ if (style.styleSheet) {
35559
+ style.styleSheet.cssText = css;
35560
+ } else {
35561
+ style.appendChild(doc.createTextNode(css));
35562
+ }
35563
+ head.appendChild(style);
35564
+ }
35565
+ };
35566
+ const addResizeListener = function (element, fn) {
35567
+ if (attachEvent) {
35568
+ element.attachEvent("onresize", fn);
35569
+ } else {
35570
+ if (!element.__resizeTriggers__) {
35571
+ const doc = element.ownerDocument;
35572
+ const elementStyle = windowObject.getComputedStyle(element);
35573
+ if (elementStyle && elementStyle.position === "static") {
35574
+ element.style.position = "relative";
35575
+ }
35576
+ createStyles(doc);
35577
+ element.__resizeLast__ = {};
35578
+ element.__resizeListeners__ = [];
35579
+ (element.__resizeTriggers__ = doc.createElement("div")).className = "resize-triggers";
35580
+ const expandTrigger = doc.createElement("div");
35581
+ expandTrigger.className = "expand-trigger";
35582
+ expandTrigger.appendChild(doc.createElement("div"));
35583
+ const contractTrigger = doc.createElement("div");
35584
+ contractTrigger.className = "contract-trigger";
35585
+ element.__resizeTriggers__.appendChild(expandTrigger);
35586
+ element.__resizeTriggers__.appendChild(contractTrigger);
35587
+ element.appendChild(element.__resizeTriggers__);
35588
+ resetTriggers(element);
35589
+ element.addEventListener("scroll", scrollListener, true);
35590
+
35591
+ /* Listen for a css animation to detect element display/re-attach */
35592
+ if (animationStartEvent) {
35593
+ element.__resizeTriggers__.__animationListener__ = function animationListener(e) {
35594
+ if (e.animationName === animationName) {
35595
+ resetTriggers(element);
35596
+ }
35597
+ };
35598
+ element.__resizeTriggers__.addEventListener(animationStartEvent, element.__resizeTriggers__.__animationListener__);
35599
+ }
35600
+ }
35601
+ element.__resizeListeners__.push(fn);
35602
+ }
35603
+ };
35604
+ const removeResizeListener = function (element, fn) {
35605
+ if (attachEvent) {
35606
+ element.detachEvent("onresize", fn);
35607
+ } else {
35608
+ element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
35609
+ if (!element.__resizeListeners__.length) {
35610
+ element.removeEventListener("scroll", scrollListener, true);
35611
+ if (element.__resizeTriggers__.__animationListener__) {
35612
+ element.__resizeTriggers__.removeEventListener(animationStartEvent, element.__resizeTriggers__.__animationListener__);
35613
+ element.__resizeTriggers__.__animationListener__ = null;
35614
+ }
35615
+ try {
35616
+ element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
35617
+ } catch (e) {
35618
+ // Preact compat; see developit/preact-compat/issues/228
35619
+ }
35620
+ }
35621
+ }
35622
+ };
35623
+ return {
35624
+ addResizeListener,
35625
+ removeResizeListener
35626
+ };
35627
+ }
35628
+
35629
+ class AutoSizer extends Component {
35630
+ constructor(...args) {
35631
+ super(...args);
35632
+ this.state = {
35633
+ height: this.props.defaultHeight || 0,
35634
+ scaledHeight: this.props.defaultHeight || 0,
35635
+ scaledWidth: this.props.defaultWidth || 0,
35636
+ width: this.props.defaultWidth || 0
35637
+ };
35638
+ this._autoSizer = null;
35639
+ this._detectElementResize = null;
35640
+ this._parentNode = null;
35641
+ this._resizeObserver = null;
35642
+ this._timeoutId = null;
35643
+ this._onResize = () => {
35644
+ this._timeoutId = null;
35645
+ const {
35646
+ disableHeight,
35647
+ disableWidth,
35648
+ onResize
35649
+ } = this.props;
35650
+ if (this._parentNode) {
35651
+ // Guard against AutoSizer component being removed from the DOM immediately after being added.
35652
+ // This can result in invalid style values which can result in NaN values if we don't handle them.
35653
+ // See issue #150 for more context.
35654
+
35655
+ const style = window.getComputedStyle(this._parentNode) || {};
35656
+ const paddingLeft = parseFloat(style.paddingLeft || "0");
35657
+ const paddingRight = parseFloat(style.paddingRight || "0");
35658
+ const paddingTop = parseFloat(style.paddingTop || "0");
35659
+ const paddingBottom = parseFloat(style.paddingBottom || "0");
35660
+ const rect = this._parentNode.getBoundingClientRect();
35661
+ const scaledHeight = rect.height - paddingTop - paddingBottom;
35662
+ const scaledWidth = rect.width - paddingLeft - paddingRight;
35663
+ const height = this._parentNode.offsetHeight - paddingTop - paddingBottom;
35664
+ const width = this._parentNode.offsetWidth - paddingLeft - paddingRight;
35665
+ if (!disableHeight && (this.state.height !== height || this.state.scaledHeight !== scaledHeight) || !disableWidth && (this.state.width !== width || this.state.scaledWidth !== scaledWidth)) {
35666
+ this.setState({
35667
+ height,
35668
+ width,
35669
+ scaledHeight,
35670
+ scaledWidth
35671
+ });
35672
+ if (typeof onResize === "function") {
35673
+ onResize({
35674
+ height,
35675
+ scaledHeight,
35676
+ scaledWidth,
35677
+ width
35678
+ });
35679
+ }
35680
+ }
35681
+ }
35682
+ };
35683
+ this._setRef = autoSizer => {
35684
+ this._autoSizer = autoSizer;
35685
+ };
35686
+ }
35687
+ componentDidMount() {
35688
+ const {
35689
+ nonce
35690
+ } = this.props;
35691
+ const parentNode = this._autoSizer ? this._autoSizer.parentNode : null;
35692
+ if (parentNode != null && parentNode.ownerDocument && parentNode.ownerDocument.defaultView && parentNode instanceof parentNode.ownerDocument.defaultView.HTMLElement) {
35693
+ // Delay access of parentNode until mount.
35694
+ // This handles edge-cases where the component has already been unmounted before its ref has been set,
35695
+ // As well as libraries like react-lite which have a slightly different lifecycle.
35696
+ this._parentNode = parentNode;
35697
+
35698
+ // Use ResizeObserver from the same context where parentNode (which we will observe) was defined
35699
+ // Using just global can result into onResize events not being emitted in cases with multiple realms
35700
+ const ResizeObserverInstance = parentNode.ownerDocument.defaultView.ResizeObserver;
35701
+ if (ResizeObserverInstance != null) {
35702
+ this._resizeObserver = new ResizeObserverInstance(() => {
35703
+ // Guard against "ResizeObserver loop limit exceeded" error;
35704
+ // could be triggered if the state update causes the ResizeObserver handler to run long.
35705
+ // See https://github.com/bvaughn/react-virtualized-auto-sizer/issues/55
35706
+ this._timeoutId = setTimeout(this._onResize, 0);
35707
+ });
35708
+ this._resizeObserver.observe(parentNode);
35709
+ } else {
35710
+ // Defer requiring resize handler in order to support server-side rendering.
35711
+ // See issue #41
35712
+ this._detectElementResize = createDetectElementResize(nonce);
35713
+ this._detectElementResize.addResizeListener(parentNode, this._onResize);
35714
+ }
35715
+ this._onResize();
35716
+ }
35717
+ }
35718
+ componentWillUnmount() {
35719
+ if (this._parentNode) {
35720
+ if (this._detectElementResize) {
35721
+ this._detectElementResize.removeResizeListener(this._parentNode, this._onResize);
35722
+ }
35723
+ if (this._timeoutId !== null) {
35724
+ clearTimeout(this._timeoutId);
35725
+ }
35726
+ if (this._resizeObserver) {
35727
+ this._resizeObserver.disconnect();
35728
+ }
35729
+ }
35730
+ }
35731
+ render() {
35732
+ const {
35733
+ children,
35734
+ defaultHeight,
35735
+ defaultWidth,
35736
+ disableHeight = false,
35737
+ disableWidth = false,
35738
+ doNotBailOutOnEmptyChildren = false,
35739
+ nonce,
35740
+ onResize,
35741
+ style = {},
35742
+ tagName = "div",
35743
+ ...rest
35744
+ } = this.props;
35745
+ const {
35746
+ height,
35747
+ scaledHeight,
35748
+ scaledWidth,
35749
+ width
35750
+ } = this.state;
35751
+
35752
+ // Outer div should not force width/height since that may prevent containers from shrinking.
35753
+ // Inner component should overflow and use calculated width/height.
35754
+ // See issue #68 for more information.
35755
+ const outerStyle = {
35756
+ overflow: "visible"
35757
+ };
35758
+ const childParams = {};
35759
+
35760
+ // Avoid rendering children before the initial measurements have been collected.
35761
+ // At best this would just be wasting cycles.
35762
+ let bailoutOnChildren = false;
35763
+ if (!disableHeight) {
35764
+ if (height === 0) {
35765
+ bailoutOnChildren = true;
35766
+ }
35767
+ outerStyle.height = 0;
35768
+ childParams.height = height;
35769
+ childParams.scaledHeight = scaledHeight;
35770
+ }
35771
+ if (!disableWidth) {
35772
+ if (width === 0) {
35773
+ bailoutOnChildren = true;
35774
+ }
35775
+ outerStyle.width = 0;
35776
+ childParams.width = width;
35777
+ childParams.scaledWidth = scaledWidth;
35778
+ }
35779
+ if (doNotBailOutOnEmptyChildren) {
35780
+ bailoutOnChildren = false;
35781
+ }
35782
+ return createElement(tagName, {
35783
+ ref: this._setRef,
35784
+ style: {
35785
+ ...outerStyle,
35786
+ ...style
35787
+ },
35788
+ ...rest
35789
+ }, !bailoutOnChildren && children(childParams));
35790
+ }
35791
+ }
35792
+
35793
+ var styles = {"table":"Ui89VirtualTable-module_table__TkJv-","tableBody":"Ui89VirtualTable-module_tableBody__S53mE","empty":"Ui89VirtualTable-module_empty__0TQZA","tableHeader":"Ui89VirtualTable-module_tableHeader__gK1W1","cell":"Ui89VirtualTable-module_cell__yecQB","cell--column-first":"Ui89VirtualTable-module_cell--column-first__ymIC-","cell--column-last":"Ui89VirtualTable-module_cell--column-last__fEGx6"};
35794
+
35795
+ const HEADER_HEIGHT = 30;
35796
+ function Ui89VirtualTable(props) {
35797
+ const rows = useMemo(() => {
35798
+ return props.rows !== undefined ? props.rows : [];
35799
+ }, [props.rows]);
35800
+ const columns = useMemo(() => {
35801
+ return props.columns !== undefined ? props.columns : [];
35802
+ }, [props.columns]);
35803
+ function getRowHeight(index) {
35804
+ if (index === 0) {
35805
+ // Header.
35806
+ return HEADER_HEIGHT;
35807
+ }
35808
+ else {
35809
+ // Body
35810
+ return props.rowHeight ?? 50;
35811
+ }
35812
+ }
35813
+ function getColumnWidth(index) {
35814
+ return columns[index].width ?? 100;
35815
+ }
35816
+ function getColumnHorizontalOffset(columnIndex) {
35817
+ let offset = 0;
35818
+ for (let i = 0; i < columnIndex; i++) {
35819
+ offset += getColumnWidth(columnIndex);
35820
+ }
35821
+ return offset;
35822
+ }
35823
+ function getColumnClass(columnIndex, rowIndex) {
35824
+ const classes = [styles.cell];
35825
+ if (rowIndex === 0) {
35826
+ classes.push(styles["cell--header"]);
35827
+ }
35828
+ if (columnIndex === 0) {
35829
+ classes.push(styles["cell--column-first"]);
35830
+ }
35831
+ if (columnIndex === columns.length - 1) {
35832
+ classes.push(styles["cell--column-last"]);
35833
+ }
35834
+ return classes.join(" ");
35835
+ }
35836
+ // This is the secret to having sticky headers.
35837
+ const innerElementType = forwardRef(({ children, ...rest }, ref) => (React__default.createElement("div", { ref: ref, ...rest },
35838
+ React__default.createElement("div", { className: styles.tableHeader }, columns.map((column, index) => (React__default.createElement("div", { className: getColumnClass(index, 0), style: {
35839
+ left: getColumnHorizontalOffset(index),
35840
+ width: getColumnWidth(index) + "px",
35841
+ height: getRowHeight(0) + "px",
35842
+ } }, column.renderHeader !== undefined && (React__default.createElement(column.renderHeader, { index: index, column: column })))))),
35843
+ children)));
35844
+ return (React__default.createElement("div", { className: styles.table }, rows.length > 0 ? (React__default.createElement("div", { className: styles.tableBody },
35845
+ React__default.createElement(AutoSizer, null, ({ height, width }) => (React__default.createElement(VariableSizeGrid, { columnCount: columns.length, columnWidth: getColumnWidth, rowCount: rows.length + 1, rowHeight: getRowHeight, width: width, height: height, innerElementType: innerElementType }, ({ columnIndex, rowIndex, style }) => (React__default.createElement("div", { className: getColumnClass(columnIndex, rowIndex), style: style }, rowIndex !== 0 &&
35846
+ [columns[columnIndex].renderBody].map((BodyContent) => (React__default.createElement(BodyContent, { index: rowIndex - 1, row: rows[rowIndex - 1] })))))))))) : (React__default.createElement("div", { className: styles.empty },
35847
+ React__default.createElement(Ui89TagBox, { theme: "warn" }, "Empty")))));
34335
35848
  }
34336
35849
 
34337
- export { Ui89Button, Ui89Card, Ui89HighlightText, Ui89Look, Ui89ModalDialog, Ui89Scene, Ui89Shortcut, Ui89SpaceVertical, Ui89TabbedCard, Ui89Tabs, Ui89TagBox, Ui89Theme, Ui89TitleBox, Ui89TitleUnderline };
35850
+ export { Ui89Button, Ui89Card, Ui89HighlightText, Ui89Look, Ui89ModalDialog, Ui89Scene, Ui89Shortcut, Ui89SpaceVertical, Ui89TabbedCard, Ui89Tabs, Ui89TagBox, Ui89Theme, Ui89TitleBox, Ui89TitleUnderline, Ui89VirtualTable };
34338
35851
  //# sourceMappingURL=index.js.map