@opengeoweb/warnings 8.3.0 → 8.4.0

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/index.esm.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
- import React__default, { useContext, useRef, useCallback, useDebugValue, Fragment, useState, useEffect } from 'react';
2
+ import React__default, { useContext, useRef, useCallback, useDebugValue, createElement, PureComponent, useState, useEffect } from 'react';
3
3
  import 'react-dom';
4
4
  import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, breakpoints, CoastalEvent, Fog, TemperatureHigh, TemperatureLow, Rain, Snow, Lightning, Wind } from '@opengeoweb/theme';
5
5
  import { uiActions, uiTypes, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, mapStoreActions, drawtoolActions, layerActions, snackbarActions } from '@opengeoweb/store';
6
6
  import { emptyGeoJSON, MapControlButton, getGeoJSONPropertyValue, getIcon, currentlySupportedDrawModes } from '@opengeoweb/webmap-react';
7
7
  import { useSetupDialog } from '@opengeoweb/core';
8
- import { dateUtils, ToggleMenu, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, CustomIconButton, SwitchButton, isAxiosError } from '@opengeoweb/shared';
9
- import { Typography, List, ListItem, Paper, ListItemButton, Stack, LinearProgress, Box, Button, Grid, FormHelperText, MenuItem, Tabs, Tab, FormControl, Card, CardContent, styled, ListItemIcon, FormControlLabel, Radio } from '@mui/material';
8
+ import { dateUtils, ToggleMenu, getHeight, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, CustomIconButton, SwitchButton, isAxiosError } from '@opengeoweb/shared';
9
+ import { Box, Typography, ListItem, Paper, ListItemButton, Stack, LinearProgress, Button, Grid, FormHelperText, MenuItem, Tabs, Tab, FormControl, Card, CardContent, styled, ListItemIcon, FormControlLabel, Radio } from '@mui/material';
10
10
  import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider } from '@opengeoweb/api';
11
11
  import { ReactHookFormProvider, defaultFormOptions, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormDateTime, ReactHookFormRadioGroup } from '@opengeoweb/form-fields';
12
12
 
@@ -486,12 +486,12 @@ function getContext() {
486
486
 
487
487
  const ReactReduxContext = /*#__PURE__*/getContext();
488
488
 
489
- /**
490
- * Hook factory, which creates a `useReduxContext` hook bound to a given context. This is a low-level
491
- * hook that you should usually not need to call directly.
492
- *
493
- * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
494
- * @returns {Function} A `useReduxContext` hook bound to the specified context.
489
+ /**
490
+ * Hook factory, which creates a `useReduxContext` hook bound to a given context. This is a low-level
491
+ * hook that you should usually not need to call directly.
492
+ *
493
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
494
+ * @returns {Function} A `useReduxContext` hook bound to the specified context.
495
495
  */
496
496
  function createReduxContextHook(context = ReactReduxContext) {
497
497
  return function useReduxContext() {
@@ -504,21 +504,21 @@ function createReduxContextHook(context = ReactReduxContext) {
504
504
  return contextValue;
505
505
  };
506
506
  }
507
- /**
508
- * A hook to access the value of the `ReactReduxContext`. This is a low-level
509
- * hook that you should usually not need to call directly.
510
- *
511
- * @returns {any} the value of the `ReactReduxContext`
512
- *
513
- * @example
514
- *
515
- * import React from 'react'
516
- * import { useReduxContext } from 'react-redux'
517
- *
518
- * export const CounterComponent = () => {
519
- * const { store } = useReduxContext()
520
- * return <div>{store.getState()}</div>
521
- * }
507
+ /**
508
+ * A hook to access the value of the `ReactReduxContext`. This is a low-level
509
+ * hook that you should usually not need to call directly.
510
+ *
511
+ * @returns {any} the value of the `ReactReduxContext`
512
+ *
513
+ * @example
514
+ *
515
+ * import React from 'react'
516
+ * import { useReduxContext } from 'react-redux'
517
+ *
518
+ * export const CounterComponent = () => {
519
+ * const { store } = useReduxContext()
520
+ * return <div>{store.getState()}</div>
521
+ * }
522
522
  */
523
523
 
524
524
  const useReduxContext = /*#__PURE__*/createReduxContextHook();
@@ -533,11 +533,11 @@ const initializeUseSelector = fn => {
533
533
  };
534
534
 
535
535
  const refEquality = (a, b) => a === b;
536
- /**
537
- * Hook factory, which creates a `useSelector` hook bound to a given context.
538
- *
539
- * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
540
- * @returns {Function} A `useSelector` hook bound to the specified context.
536
+ /**
537
+ * Hook factory, which creates a `useSelector` hook bound to a given context.
538
+ *
539
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
540
+ * @returns {Function} A `useSelector` hook bound to the specified context.
541
541
  */
542
542
 
543
543
 
@@ -585,10 +585,21 @@ function createSelectorHook(context = ReactReduxContext) {
585
585
  const toCompare = selector(state);
586
586
 
587
587
  if (!equalityFn(selected, toCompare)) {
588
+ let stack = undefined;
589
+
590
+ try {
591
+ throw new Error();
592
+ } catch (e) {
593
+ ({
594
+ stack
595
+ } = e);
596
+ }
597
+
588
598
  console.warn('Selector ' + (selector.name || 'unknown') + ' returned a different result when called with the same parameters. This can lead to unnecessary rerenders.' + '\nSelectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization', {
589
599
  state,
590
600
  selected,
591
- selected2: toCompare
601
+ selected2: toCompare,
602
+ stack
592
603
  });
593
604
  }
594
605
  }
@@ -598,7 +609,19 @@ function createSelectorHook(context = ReactReduxContext) {
598
609
  if (finalNoopCheck === 'always' || finalNoopCheck === 'once' && firstRun.current) {
599
610
  // @ts-ignore
600
611
  if (selected === state) {
601
- console.warn('Selector ' + (selector.name || 'unknown') + ' returned the root state when called. This can lead to unnecessary rerenders.' + '\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.');
612
+ let stack = undefined;
613
+
614
+ try {
615
+ throw new Error();
616
+ } catch (e) {
617
+ ({
618
+ stack
619
+ } = e);
620
+ }
621
+
622
+ console.warn('Selector ' + (selector.name || 'unknown') + ' returned the root state when called. This can lead to unnecessary rerenders.' + '\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.', {
623
+ stack
624
+ });
602
625
  }
603
626
  }
604
627
 
@@ -614,32 +637,47 @@ function createSelectorHook(context = ReactReduxContext) {
614
637
  return selectedState;
615
638
  };
616
639
  }
617
- /**
618
- * A hook to access the redux store's state. This hook takes a selector function
619
- * as an argument. The selector is called with the store state.
620
- *
621
- * This hook takes an optional equality comparison function as the second parameter
622
- * that allows you to customize the way the selected state is compared to determine
623
- * whether the component needs to be re-rendered.
624
- *
625
- * @param {Function} selector the selector function
626
- * @param {Function=} equalityFn the function that will be used to determine equality
627
- *
628
- * @returns {any} the selected state
629
- *
630
- * @example
631
- *
632
- * import React from 'react'
633
- * import { useSelector } from 'react-redux'
634
- *
635
- * export const CounterComponent = () => {
636
- * const counter = useSelector(state => state.counter)
637
- * return <div>{counter}</div>
638
- * }
640
+ /**
641
+ * A hook to access the redux store's state. This hook takes a selector function
642
+ * as an argument. The selector is called with the store state.
643
+ *
644
+ * This hook takes an optional equality comparison function as the second parameter
645
+ * that allows you to customize the way the selected state is compared to determine
646
+ * whether the component needs to be re-rendered.
647
+ *
648
+ * @param {Function} selector the selector function
649
+ * @param {Function=} equalityFn the function that will be used to determine equality
650
+ *
651
+ * @returns {any} the selected state
652
+ *
653
+ * @example
654
+ *
655
+ * import React from 'react'
656
+ * import { useSelector } from 'react-redux'
657
+ *
658
+ * export const CounterComponent = () => {
659
+ * const counter = useSelector(state => state.counter)
660
+ * return <div>{counter}</div>
661
+ * }
639
662
  */
640
663
 
641
664
  const useSelector = /*#__PURE__*/createSelectorHook();
642
665
 
666
+ function _extends() {
667
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
668
+ for (var i = 1; i < arguments.length; i++) {
669
+ var source = arguments[i];
670
+ for (var key in source) {
671
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
672
+ target[key] = source[key];
673
+ }
674
+ }
675
+ }
676
+ return target;
677
+ };
678
+ return _extends.apply(this, arguments);
679
+ }
680
+
643
681
  var reactIs$1 = {exports: {}};
644
682
 
645
683
  var reactIs_production_min$1 = {};
@@ -1106,11 +1144,11 @@ reactIs_development.typeOf = typeOf;
1106
1144
 
1107
1145
  if (process.env.NODE_ENV === 'production') ;
1108
1146
 
1109
- /**
1110
- * Hook factory, which creates a `useStore` hook bound to a given context.
1111
- *
1112
- * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
1113
- * @returns {Function} A `useStore` hook bound to the specified context.
1147
+ /**
1148
+ * Hook factory, which creates a `useStore` hook bound to a given context.
1149
+ *
1150
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
1151
+ * @returns {Function} A `useStore` hook bound to the specified context.
1114
1152
  */
1115
1153
 
1116
1154
  function createStoreHook(context = ReactReduxContext) {
@@ -1125,29 +1163,29 @@ function createStoreHook(context = ReactReduxContext) {
1125
1163
  return store;
1126
1164
  };
1127
1165
  }
1128
- /**
1129
- * A hook to access the redux store.
1130
- *
1131
- * @returns {any} the redux store
1132
- *
1133
- * @example
1134
- *
1135
- * import React from 'react'
1136
- * import { useStore } from 'react-redux'
1137
- *
1138
- * export const ExampleComponent = () => {
1139
- * const store = useStore()
1140
- * return <div>{store.getState()}</div>
1141
- * }
1166
+ /**
1167
+ * A hook to access the redux store.
1168
+ *
1169
+ * @returns {any} the redux store
1170
+ *
1171
+ * @example
1172
+ *
1173
+ * import React from 'react'
1174
+ * import { useStore } from 'react-redux'
1175
+ *
1176
+ * export const ExampleComponent = () => {
1177
+ * const store = useStore()
1178
+ * return <div>{store.getState()}</div>
1179
+ * }
1142
1180
  */
1143
1181
 
1144
1182
  const useStore = /*#__PURE__*/createStoreHook();
1145
1183
 
1146
- /**
1147
- * Hook factory, which creates a `useDispatch` hook bound to a given context.
1148
- *
1149
- * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
1150
- * @returns {Function} A `useDispatch` hook bound to the specified context.
1184
+ /**
1185
+ * Hook factory, which creates a `useDispatch` hook bound to a given context.
1186
+ *
1187
+ * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
1188
+ * @returns {Function} A `useDispatch` hook bound to the specified context.
1151
1189
  */
1152
1190
 
1153
1191
  function createDispatchHook(context = ReactReduxContext) {
@@ -1159,26 +1197,26 @@ function createDispatchHook(context = ReactReduxContext) {
1159
1197
  return store.dispatch;
1160
1198
  };
1161
1199
  }
1162
- /**
1163
- * A hook to access the redux `dispatch` function.
1164
- *
1165
- * @returns {any|function} redux store's `dispatch` function
1166
- *
1167
- * @example
1168
- *
1169
- * import React, { useCallback } from 'react'
1170
- * import { useDispatch } from 'react-redux'
1171
- *
1172
- * export const CounterComponent = ({ value }) => {
1173
- * const dispatch = useDispatch()
1174
- * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
1175
- * return (
1176
- * <div>
1177
- * <span>{value}</span>
1178
- * <button onClick={increaseCounter}>Increase counter</button>
1179
- * </div>
1180
- * )
1181
- * }
1200
+ /**
1201
+ * A hook to access the redux `dispatch` function.
1202
+ *
1203
+ * @returns {any|function} redux store's `dispatch` function
1204
+ *
1205
+ * @example
1206
+ *
1207
+ * import React, { useCallback } from 'react'
1208
+ * import { useDispatch } from 'react-redux'
1209
+ *
1210
+ * export const CounterComponent = ({ value }) => {
1211
+ * const dispatch = useDispatch()
1212
+ * const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
1213
+ * return (
1214
+ * <div>
1215
+ * <span>{value}</span>
1216
+ * <button onClick={increaseCounter}>Increase counter</button>
1217
+ * </div>
1218
+ * )
1219
+ * }
1182
1220
  */
1183
1221
 
1184
1222
  const useDispatch = /*#__PURE__*/createDispatchHook();
@@ -1555,6 +1593,39 @@ function isPlainObject(value) {
1555
1593
  }
1556
1594
  return proto === baseProto;
1557
1595
  }
1596
+ // src/createAction.ts
1597
+ function createAction(type, prepareAction) {
1598
+ function actionCreator() {
1599
+ var args = [];
1600
+ for (var _i = 0; _i < arguments.length; _i++) {
1601
+ args[_i] = arguments[_i];
1602
+ }
1603
+ if (prepareAction) {
1604
+ var prepared = prepareAction.apply(void 0, args);
1605
+ if (!prepared) {
1606
+ throw new Error("prepareAction did not return an object");
1607
+ }
1608
+ return __spreadValues(__spreadValues({
1609
+ type: type,
1610
+ payload: prepared.payload
1611
+ }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
1612
+ }
1613
+ return { type: type, payload: args[0] };
1614
+ }
1615
+ actionCreator.toString = function () { return "" + type; };
1616
+ actionCreator.type = type;
1617
+ actionCreator.match = function (action) { return action.type === type; };
1618
+ return actionCreator;
1619
+ }
1620
+ function isAction(action) {
1621
+ return isPlainObject(action) && "type" in action;
1622
+ }
1623
+ function isFSA(action) {
1624
+ return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
1625
+ }
1626
+ function isValidKey(key) {
1627
+ return ["type", "payload", "error", "meta"].indexOf(key) > -1;
1628
+ }
1558
1629
  /** @class */ ((function (_super) {
1559
1630
  __extends(MiddlewareArray, _super);
1560
1631
  function MiddlewareArray() {
@@ -1637,39 +1708,6 @@ function freezeDraftable(val) {
1637
1708
  process.env.NODE_ENV === "production";
1638
1709
  // src/configureStore.ts
1639
1710
  process.env.NODE_ENV === "production";
1640
- // src/createAction.ts
1641
- function createAction(type, prepareAction) {
1642
- function actionCreator() {
1643
- var args = [];
1644
- for (var _i = 0; _i < arguments.length; _i++) {
1645
- args[_i] = arguments[_i];
1646
- }
1647
- if (prepareAction) {
1648
- var prepared = prepareAction.apply(void 0, args);
1649
- if (!prepared) {
1650
- throw new Error("prepareAction did not return an object");
1651
- }
1652
- return __spreadValues(__spreadValues({
1653
- type: type,
1654
- payload: prepared.payload
1655
- }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
1656
- }
1657
- return { type: type, payload: args[0] };
1658
- }
1659
- actionCreator.toString = function () { return "" + type; };
1660
- actionCreator.type = type;
1661
- actionCreator.match = function (action) { return action.type === type; };
1662
- return actionCreator;
1663
- }
1664
- function isAction(action) {
1665
- return isPlainObject(action) && "type" in action;
1666
- }
1667
- function isFSA(action) {
1668
- return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
1669
- }
1670
- function isValidKey(key) {
1671
- return ["type", "payload", "error", "meta"].indexOf(key) > -1;
1672
- }
1673
1711
  // src/mapBuilders.ts
1674
1712
  function executeReducerBuilderCallback(builderCallback) {
1675
1713
  var actionsMap = {};
@@ -1686,8 +1724,11 @@ function executeReducerBuilderCallback(builderCallback) {
1686
1724
  }
1687
1725
  }
1688
1726
  var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
1727
+ if (!type) {
1728
+ throw new Error("`builder.addCase` cannot be called with an empty action type");
1729
+ }
1689
1730
  if (type in actionsMap) {
1690
- throw new Error("addCase cannot be called with two reducers for the same action type");
1731
+ throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
1691
1732
  }
1692
1733
  actionsMap[type] = reducer;
1693
1734
  return builder;
@@ -3215,6 +3256,913 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
3215
3256
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3216
3257
  };
3217
3258
 
3259
+ function _assertThisInitialized(self) {
3260
+ if (self === void 0) {
3261
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3262
+ }
3263
+ return self;
3264
+ }
3265
+
3266
+ function _setPrototypeOf(o, p) {
3267
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
3268
+ o.__proto__ = p;
3269
+ return o;
3270
+ };
3271
+ return _setPrototypeOf(o, p);
3272
+ }
3273
+
3274
+ function _inheritsLoose(subClass, superClass) {
3275
+ subClass.prototype = Object.create(superClass.prototype);
3276
+ subClass.prototype.constructor = subClass;
3277
+ _setPrototypeOf(subClass, superClass);
3278
+ }
3279
+
3280
+ var safeIsNaN = Number.isNaN ||
3281
+ function ponyfill(value) {
3282
+ return typeof value === 'number' && value !== value;
3283
+ };
3284
+ function isEqual(first, second) {
3285
+ if (first === second) {
3286
+ return true;
3287
+ }
3288
+ if (safeIsNaN(first) && safeIsNaN(second)) {
3289
+ return true;
3290
+ }
3291
+ return false;
3292
+ }
3293
+ function areInputsEqual(newInputs, lastInputs) {
3294
+ if (newInputs.length !== lastInputs.length) {
3295
+ return false;
3296
+ }
3297
+ for (var i = 0; i < newInputs.length; i++) {
3298
+ if (!isEqual(newInputs[i], lastInputs[i])) {
3299
+ return false;
3300
+ }
3301
+ }
3302
+ return true;
3303
+ }
3304
+
3305
+ function memoizeOne(resultFn, isEqual) {
3306
+ if (isEqual === void 0) { isEqual = areInputsEqual; }
3307
+ var lastThis;
3308
+ var lastArgs = [];
3309
+ var lastResult;
3310
+ var calledOnce = false;
3311
+ function memoized() {
3312
+ var newArgs = [];
3313
+ for (var _i = 0; _i < arguments.length; _i++) {
3314
+ newArgs[_i] = arguments[_i];
3315
+ }
3316
+ if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
3317
+ return lastResult;
3318
+ }
3319
+ lastResult = resultFn.apply(this, newArgs);
3320
+ calledOnce = true;
3321
+ lastThis = this;
3322
+ lastArgs = newArgs;
3323
+ return lastResult;
3324
+ }
3325
+ return memoized;
3326
+ }
3327
+
3328
+ // Animation frame based implementation of setTimeout.
3329
+ // Inspired by Joe Lambert, https://gist.github.com/joelambert/1002116#file-requesttimeout-js
3330
+ var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
3331
+ var now = hasNativePerformanceNow ? function () {
3332
+ return performance.now();
3333
+ } : function () {
3334
+ return Date.now();
3335
+ };
3336
+ function cancelTimeout(timeoutID) {
3337
+ cancelAnimationFrame(timeoutID.id);
3338
+ }
3339
+ function requestTimeout(callback, delay) {
3340
+ var start = now();
3341
+
3342
+ function tick() {
3343
+ if (now() - start >= delay) {
3344
+ callback.call(null);
3345
+ } else {
3346
+ timeoutID.id = requestAnimationFrame(tick);
3347
+ }
3348
+ }
3349
+
3350
+ var timeoutID = {
3351
+ id: requestAnimationFrame(tick)
3352
+ };
3353
+ return timeoutID;
3354
+ }
3355
+
3356
+ var size = -1; // This utility copied from "dom-helpers" package.
3357
+
3358
+ function getScrollbarSize(recalculate) {
3359
+ if (recalculate === void 0) {
3360
+ recalculate = false;
3361
+ }
3362
+
3363
+ if (size === -1 || recalculate) {
3364
+ var div = document.createElement('div');
3365
+ var style = div.style;
3366
+ style.width = '50px';
3367
+ style.height = '50px';
3368
+ style.overflow = 'scroll';
3369
+ document.body.appendChild(div);
3370
+ size = div.offsetWidth - div.clientWidth;
3371
+ document.body.removeChild(div);
3372
+ }
3373
+
3374
+ return size;
3375
+ }
3376
+ var cachedRTLResult = null; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
3377
+ // Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
3378
+ // Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
3379
+ // The safest way to check this is to intentionally set a negative offset,
3380
+ // and then verify that the subsequent "scroll" event matches the negative offset.
3381
+ // If it does not match, then we can assume a non-standard RTL scroll implementation.
3382
+
3383
+ function getRTLOffsetType(recalculate) {
3384
+ if (recalculate === void 0) {
3385
+ recalculate = false;
3386
+ }
3387
+
3388
+ if (cachedRTLResult === null || recalculate) {
3389
+ var outerDiv = document.createElement('div');
3390
+ var outerStyle = outerDiv.style;
3391
+ outerStyle.width = '50px';
3392
+ outerStyle.height = '50px';
3393
+ outerStyle.overflow = 'scroll';
3394
+ outerStyle.direction = 'rtl';
3395
+ var innerDiv = document.createElement('div');
3396
+ var innerStyle = innerDiv.style;
3397
+ innerStyle.width = '100px';
3398
+ innerStyle.height = '100px';
3399
+ outerDiv.appendChild(innerDiv);
3400
+ document.body.appendChild(outerDiv);
3401
+
3402
+ if (outerDiv.scrollLeft > 0) {
3403
+ cachedRTLResult = 'positive-descending';
3404
+ } else {
3405
+ outerDiv.scrollLeft = 1;
3406
+
3407
+ if (outerDiv.scrollLeft === 0) {
3408
+ cachedRTLResult = 'negative';
3409
+ } else {
3410
+ cachedRTLResult = 'positive-ascending';
3411
+ }
3412
+ }
3413
+
3414
+ document.body.removeChild(outerDiv);
3415
+ return cachedRTLResult;
3416
+ }
3417
+
3418
+ return cachedRTLResult;
3419
+ }
3420
+
3421
+ if (process.env.NODE_ENV !== 'production') ;
3422
+
3423
+ var IS_SCROLLING_DEBOUNCE_INTERVAL$1 = 150;
3424
+
3425
+ var defaultItemKey$1 = function defaultItemKey(index, data) {
3426
+ return index;
3427
+ }; // In DEV mode, this Set helps us only log a warning once per component instance.
3428
+ // This avoids spamming the console every time a render happens.
3429
+
3430
+
3431
+ var devWarningsDirection = null;
3432
+ var devWarningsTagName$1 = null;
3433
+
3434
+ if (process.env.NODE_ENV !== 'production') {
3435
+ if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
3436
+ devWarningsDirection = /*#__PURE__*/new WeakSet();
3437
+ devWarningsTagName$1 = /*#__PURE__*/new WeakSet();
3438
+ }
3439
+ }
3440
+
3441
+ function createListComponent(_ref) {
3442
+ var _class;
3443
+
3444
+ var getItemOffset = _ref.getItemOffset,
3445
+ getEstimatedTotalSize = _ref.getEstimatedTotalSize,
3446
+ getItemSize = _ref.getItemSize,
3447
+ getOffsetForIndexAndAlignment = _ref.getOffsetForIndexAndAlignment,
3448
+ getStartIndexForOffset = _ref.getStartIndexForOffset,
3449
+ getStopIndexForStartIndex = _ref.getStopIndexForStartIndex,
3450
+ initInstanceProps = _ref.initInstanceProps,
3451
+ shouldResetStyleCacheOnItemSizeChange = _ref.shouldResetStyleCacheOnItemSizeChange,
3452
+ validateProps = _ref.validateProps;
3453
+ return _class = /*#__PURE__*/function (_PureComponent) {
3454
+ _inheritsLoose(List, _PureComponent);
3455
+
3456
+ // Always use explicit constructor for React components.
3457
+ // It produces less code after transpilation. (#26)
3458
+ // eslint-disable-next-line no-useless-constructor
3459
+ function List(props) {
3460
+ var _this;
3461
+
3462
+ _this = _PureComponent.call(this, props) || this;
3463
+ _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_this));
3464
+ _this._outerRef = void 0;
3465
+ _this._resetIsScrollingTimeoutId = null;
3466
+ _this.state = {
3467
+ instance: _assertThisInitialized(_this),
3468
+ isScrolling: false,
3469
+ scrollDirection: 'forward',
3470
+ scrollOffset: typeof _this.props.initialScrollOffset === 'number' ? _this.props.initialScrollOffset : 0,
3471
+ scrollUpdateWasRequested: false
3472
+ };
3473
+ _this._callOnItemsRendered = void 0;
3474
+ _this._callOnItemsRendered = memoizeOne(function (overscanStartIndex, overscanStopIndex, visibleStartIndex, visibleStopIndex) {
3475
+ return _this.props.onItemsRendered({
3476
+ overscanStartIndex: overscanStartIndex,
3477
+ overscanStopIndex: overscanStopIndex,
3478
+ visibleStartIndex: visibleStartIndex,
3479
+ visibleStopIndex: visibleStopIndex
3480
+ });
3481
+ });
3482
+ _this._callOnScroll = void 0;
3483
+ _this._callOnScroll = memoizeOne(function (scrollDirection, scrollOffset, scrollUpdateWasRequested) {
3484
+ return _this.props.onScroll({
3485
+ scrollDirection: scrollDirection,
3486
+ scrollOffset: scrollOffset,
3487
+ scrollUpdateWasRequested: scrollUpdateWasRequested
3488
+ });
3489
+ });
3490
+ _this._getItemStyle = void 0;
3491
+
3492
+ _this._getItemStyle = function (index) {
3493
+ var _this$props = _this.props,
3494
+ direction = _this$props.direction,
3495
+ itemSize = _this$props.itemSize,
3496
+ layout = _this$props.layout;
3497
+
3498
+ var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize, shouldResetStyleCacheOnItemSizeChange && layout, shouldResetStyleCacheOnItemSizeChange && direction);
3499
+
3500
+ var style;
3501
+
3502
+ if (itemStyleCache.hasOwnProperty(index)) {
3503
+ style = itemStyleCache[index];
3504
+ } else {
3505
+ var _offset = getItemOffset(_this.props, index, _this._instanceProps);
3506
+
3507
+ var size = getItemSize(_this.props, index, _this._instanceProps); // TODO Deprecate direction "horizontal"
3508
+
3509
+ var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
3510
+ var isRtl = direction === 'rtl';
3511
+ var offsetHorizontal = isHorizontal ? _offset : 0;
3512
+ itemStyleCache[index] = style = {
3513
+ position: 'absolute',
3514
+ left: isRtl ? undefined : offsetHorizontal,
3515
+ right: isRtl ? offsetHorizontal : undefined,
3516
+ top: !isHorizontal ? _offset : 0,
3517
+ height: !isHorizontal ? size : '100%',
3518
+ width: isHorizontal ? size : '100%'
3519
+ };
3520
+ }
3521
+
3522
+ return style;
3523
+ };
3524
+
3525
+ _this._getItemStyleCache = void 0;
3526
+ _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
3527
+ return {};
3528
+ });
3529
+
3530
+ _this._onScrollHorizontal = function (event) {
3531
+ var _event$currentTarget = event.currentTarget,
3532
+ clientWidth = _event$currentTarget.clientWidth,
3533
+ scrollLeft = _event$currentTarget.scrollLeft,
3534
+ scrollWidth = _event$currentTarget.scrollWidth;
3535
+
3536
+ _this.setState(function (prevState) {
3537
+ if (prevState.scrollOffset === scrollLeft) {
3538
+ // Scroll position may have been updated by cDM/cDU,
3539
+ // In which case we don't need to trigger another render,
3540
+ // And we don't want to update state.isScrolling.
3541
+ return null;
3542
+ }
3543
+
3544
+ var direction = _this.props.direction;
3545
+ var scrollOffset = scrollLeft;
3546
+
3547
+ if (direction === 'rtl') {
3548
+ // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
3549
+ // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
3550
+ // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
3551
+ // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
3552
+ switch (getRTLOffsetType()) {
3553
+ case 'negative':
3554
+ scrollOffset = -scrollLeft;
3555
+ break;
3556
+
3557
+ case 'positive-descending':
3558
+ scrollOffset = scrollWidth - clientWidth - scrollLeft;
3559
+ break;
3560
+ }
3561
+ } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
3562
+
3563
+
3564
+ scrollOffset = Math.max(0, Math.min(scrollOffset, scrollWidth - clientWidth));
3565
+ return {
3566
+ isScrolling: true,
3567
+ scrollDirection: prevState.scrollOffset < scrollLeft ? 'forward' : 'backward',
3568
+ scrollOffset: scrollOffset,
3569
+ scrollUpdateWasRequested: false
3570
+ };
3571
+ }, _this._resetIsScrollingDebounced);
3572
+ };
3573
+
3574
+ _this._onScrollVertical = function (event) {
3575
+ var _event$currentTarget2 = event.currentTarget,
3576
+ clientHeight = _event$currentTarget2.clientHeight,
3577
+ scrollHeight = _event$currentTarget2.scrollHeight,
3578
+ scrollTop = _event$currentTarget2.scrollTop;
3579
+
3580
+ _this.setState(function (prevState) {
3581
+ if (prevState.scrollOffset === scrollTop) {
3582
+ // Scroll position may have been updated by cDM/cDU,
3583
+ // In which case we don't need to trigger another render,
3584
+ // And we don't want to update state.isScrolling.
3585
+ return null;
3586
+ } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
3587
+
3588
+
3589
+ var scrollOffset = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
3590
+ return {
3591
+ isScrolling: true,
3592
+ scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
3593
+ scrollOffset: scrollOffset,
3594
+ scrollUpdateWasRequested: false
3595
+ };
3596
+ }, _this._resetIsScrollingDebounced);
3597
+ };
3598
+
3599
+ _this._outerRefSetter = function (ref) {
3600
+ var outerRef = _this.props.outerRef;
3601
+ _this._outerRef = ref;
3602
+
3603
+ if (typeof outerRef === 'function') {
3604
+ outerRef(ref);
3605
+ } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
3606
+ outerRef.current = ref;
3607
+ }
3608
+ };
3609
+
3610
+ _this._resetIsScrollingDebounced = function () {
3611
+ if (_this._resetIsScrollingTimeoutId !== null) {
3612
+ cancelTimeout(_this._resetIsScrollingTimeoutId);
3613
+ }
3614
+
3615
+ _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL$1);
3616
+ };
3617
+
3618
+ _this._resetIsScrolling = function () {
3619
+ _this._resetIsScrollingTimeoutId = null;
3620
+
3621
+ _this.setState({
3622
+ isScrolling: false
3623
+ }, function () {
3624
+ // Clear style cache after state update has been committed.
3625
+ // This way we don't break pure sCU for items that don't use isScrolling param.
3626
+ _this._getItemStyleCache(-1, null);
3627
+ });
3628
+ };
3629
+
3630
+ return _this;
3631
+ }
3632
+
3633
+ List.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
3634
+ validateSharedProps$1(nextProps, prevState);
3635
+ validateProps(nextProps);
3636
+ return null;
3637
+ };
3638
+
3639
+ var _proto = List.prototype;
3640
+
3641
+ _proto.scrollTo = function scrollTo(scrollOffset) {
3642
+ scrollOffset = Math.max(0, scrollOffset);
3643
+ this.setState(function (prevState) {
3644
+ if (prevState.scrollOffset === scrollOffset) {
3645
+ return null;
3646
+ }
3647
+
3648
+ return {
3649
+ scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
3650
+ scrollOffset: scrollOffset,
3651
+ scrollUpdateWasRequested: true
3652
+ };
3653
+ }, this._resetIsScrollingDebounced);
3654
+ };
3655
+
3656
+ _proto.scrollToItem = function scrollToItem(index, align) {
3657
+ if (align === void 0) {
3658
+ align = 'auto';
3659
+ }
3660
+
3661
+ var _this$props2 = this.props,
3662
+ itemCount = _this$props2.itemCount,
3663
+ layout = _this$props2.layout;
3664
+ var scrollOffset = this.state.scrollOffset;
3665
+ 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.
3666
+ // But we only need to account for its size when it's actually visible.
3667
+ // This is an edge case for lists; normally they only scroll in the dominant direction.
3668
+
3669
+ var scrollbarSize = 0;
3670
+
3671
+ if (this._outerRef) {
3672
+ var outerRef = this._outerRef;
3673
+
3674
+ if (layout === 'vertical') {
3675
+ scrollbarSize = outerRef.scrollWidth > outerRef.clientWidth ? getScrollbarSize() : 0;
3676
+ } else {
3677
+ scrollbarSize = outerRef.scrollHeight > outerRef.clientHeight ? getScrollbarSize() : 0;
3678
+ }
3679
+ }
3680
+
3681
+ this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps, scrollbarSize));
3682
+ };
3683
+
3684
+ _proto.componentDidMount = function componentDidMount() {
3685
+ var _this$props3 = this.props,
3686
+ direction = _this$props3.direction,
3687
+ initialScrollOffset = _this$props3.initialScrollOffset,
3688
+ layout = _this$props3.layout;
3689
+
3690
+ if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
3691
+ var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
3692
+
3693
+ if (direction === 'horizontal' || layout === 'horizontal') {
3694
+ outerRef.scrollLeft = initialScrollOffset;
3695
+ } else {
3696
+ outerRef.scrollTop = initialScrollOffset;
3697
+ }
3698
+ }
3699
+
3700
+ this._callPropsCallbacks();
3701
+ };
3702
+
3703
+ _proto.componentDidUpdate = function componentDidUpdate() {
3704
+ var _this$props4 = this.props,
3705
+ direction = _this$props4.direction,
3706
+ layout = _this$props4.layout;
3707
+ var _this$state = this.state,
3708
+ scrollOffset = _this$state.scrollOffset,
3709
+ scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
3710
+
3711
+ if (scrollUpdateWasRequested && this._outerRef != null) {
3712
+ var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
3713
+
3714
+ if (direction === 'horizontal' || layout === 'horizontal') {
3715
+ if (direction === 'rtl') {
3716
+ // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
3717
+ // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
3718
+ // So we need to determine which browser behavior we're dealing with, and mimic it.
3719
+ switch (getRTLOffsetType()) {
3720
+ case 'negative':
3721
+ outerRef.scrollLeft = -scrollOffset;
3722
+ break;
3723
+
3724
+ case 'positive-ascending':
3725
+ outerRef.scrollLeft = scrollOffset;
3726
+ break;
3727
+
3728
+ default:
3729
+ var clientWidth = outerRef.clientWidth,
3730
+ scrollWidth = outerRef.scrollWidth;
3731
+ outerRef.scrollLeft = scrollWidth - clientWidth - scrollOffset;
3732
+ break;
3733
+ }
3734
+ } else {
3735
+ outerRef.scrollLeft = scrollOffset;
3736
+ }
3737
+ } else {
3738
+ outerRef.scrollTop = scrollOffset;
3739
+ }
3740
+ }
3741
+
3742
+ this._callPropsCallbacks();
3743
+ };
3744
+
3745
+ _proto.componentWillUnmount = function componentWillUnmount() {
3746
+ if (this._resetIsScrollingTimeoutId !== null) {
3747
+ cancelTimeout(this._resetIsScrollingTimeoutId);
3748
+ }
3749
+ };
3750
+
3751
+ _proto.render = function render() {
3752
+ var _this$props5 = this.props,
3753
+ children = _this$props5.children,
3754
+ className = _this$props5.className,
3755
+ direction = _this$props5.direction,
3756
+ height = _this$props5.height,
3757
+ innerRef = _this$props5.innerRef,
3758
+ innerElementType = _this$props5.innerElementType,
3759
+ innerTagName = _this$props5.innerTagName,
3760
+ itemCount = _this$props5.itemCount,
3761
+ itemData = _this$props5.itemData,
3762
+ _this$props5$itemKey = _this$props5.itemKey,
3763
+ itemKey = _this$props5$itemKey === void 0 ? defaultItemKey$1 : _this$props5$itemKey,
3764
+ layout = _this$props5.layout,
3765
+ outerElementType = _this$props5.outerElementType,
3766
+ outerTagName = _this$props5.outerTagName,
3767
+ style = _this$props5.style,
3768
+ useIsScrolling = _this$props5.useIsScrolling,
3769
+ width = _this$props5.width;
3770
+ var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
3771
+
3772
+ var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
3773
+ var onScroll = isHorizontal ? this._onScrollHorizontal : this._onScrollVertical;
3774
+
3775
+ var _this$_getRangeToRend = this._getRangeToRender(),
3776
+ startIndex = _this$_getRangeToRend[0],
3777
+ stopIndex = _this$_getRangeToRend[1];
3778
+
3779
+ var items = [];
3780
+
3781
+ if (itemCount > 0) {
3782
+ for (var _index = startIndex; _index <= stopIndex; _index++) {
3783
+ items.push(createElement(children, {
3784
+ data: itemData,
3785
+ key: itemKey(_index, itemData),
3786
+ index: _index,
3787
+ isScrolling: useIsScrolling ? isScrolling : undefined,
3788
+ style: this._getItemStyle(_index)
3789
+ }));
3790
+ }
3791
+ } // Read this value AFTER items have been created,
3792
+ // So their actual sizes (if variable) are taken into consideration.
3793
+
3794
+
3795
+ var estimatedTotalSize = getEstimatedTotalSize(this.props, this._instanceProps);
3796
+ return createElement(outerElementType || outerTagName || 'div', {
3797
+ className: className,
3798
+ onScroll: onScroll,
3799
+ ref: this._outerRefSetter,
3800
+ style: _extends({
3801
+ position: 'relative',
3802
+ height: height,
3803
+ width: width,
3804
+ overflow: 'auto',
3805
+ WebkitOverflowScrolling: 'touch',
3806
+ willChange: 'transform',
3807
+ direction: direction
3808
+ }, style)
3809
+ }, createElement(innerElementType || innerTagName || 'div', {
3810
+ children: items,
3811
+ ref: innerRef,
3812
+ style: {
3813
+ height: isHorizontal ? '100%' : estimatedTotalSize,
3814
+ pointerEvents: isScrolling ? 'none' : undefined,
3815
+ width: isHorizontal ? estimatedTotalSize : '100%'
3816
+ }
3817
+ }));
3818
+ };
3819
+
3820
+ _proto._callPropsCallbacks = function _callPropsCallbacks() {
3821
+ if (typeof this.props.onItemsRendered === 'function') {
3822
+ var itemCount = this.props.itemCount;
3823
+
3824
+ if (itemCount > 0) {
3825
+ var _this$_getRangeToRend2 = this._getRangeToRender(),
3826
+ _overscanStartIndex = _this$_getRangeToRend2[0],
3827
+ _overscanStopIndex = _this$_getRangeToRend2[1],
3828
+ _visibleStartIndex = _this$_getRangeToRend2[2],
3829
+ _visibleStopIndex = _this$_getRangeToRend2[3];
3830
+
3831
+ this._callOnItemsRendered(_overscanStartIndex, _overscanStopIndex, _visibleStartIndex, _visibleStopIndex);
3832
+ }
3833
+ }
3834
+
3835
+ if (typeof this.props.onScroll === 'function') {
3836
+ var _this$state2 = this.state,
3837
+ _scrollDirection = _this$state2.scrollDirection,
3838
+ _scrollOffset = _this$state2.scrollOffset,
3839
+ _scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
3840
+
3841
+ this._callOnScroll(_scrollDirection, _scrollOffset, _scrollUpdateWasRequested);
3842
+ }
3843
+ } // Lazily create and cache item styles while scrolling,
3844
+ // So that pure component sCU will prevent re-renders.
3845
+ // We maintain this cache, and pass a style prop rather than index,
3846
+ // So that List can clear cached styles and force item re-render if necessary.
3847
+ ;
3848
+
3849
+ _proto._getRangeToRender = function _getRangeToRender() {
3850
+ var _this$props6 = this.props,
3851
+ itemCount = _this$props6.itemCount,
3852
+ overscanCount = _this$props6.overscanCount;
3853
+ var _this$state3 = this.state,
3854
+ isScrolling = _this$state3.isScrolling,
3855
+ scrollDirection = _this$state3.scrollDirection,
3856
+ scrollOffset = _this$state3.scrollOffset;
3857
+
3858
+ if (itemCount === 0) {
3859
+ return [0, 0, 0, 0];
3860
+ }
3861
+
3862
+ var startIndex = getStartIndexForOffset(this.props, scrollOffset, this._instanceProps);
3863
+ var stopIndex = getStopIndexForStartIndex(this.props, startIndex, scrollOffset, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
3864
+ // If there isn't at least one extra item, tab loops back around.
3865
+
3866
+ var overscanBackward = !isScrolling || scrollDirection === 'backward' ? Math.max(1, overscanCount) : 1;
3867
+ var overscanForward = !isScrolling || scrollDirection === 'forward' ? Math.max(1, overscanCount) : 1;
3868
+ return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(itemCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
3869
+ };
3870
+
3871
+ return List;
3872
+ }(PureComponent), _class.defaultProps = {
3873
+ direction: 'ltr',
3874
+ itemData: undefined,
3875
+ layout: 'vertical',
3876
+ overscanCount: 2,
3877
+ useIsScrolling: false
3878
+ }, _class;
3879
+ } // NOTE: I considered further wrapping individual items with a pure ListItem component.
3880
+ // This would avoid ever calling the render function for the same index more than once,
3881
+ // But it would also add the overhead of a lot of components/fibers.
3882
+ // I assume people already do this (render function returning a class component),
3883
+ // So my doing it would just unnecessarily double the wrappers.
3884
+
3885
+ var validateSharedProps$1 = function validateSharedProps(_ref2, _ref3) {
3886
+ var children = _ref2.children,
3887
+ direction = _ref2.direction,
3888
+ height = _ref2.height,
3889
+ layout = _ref2.layout,
3890
+ innerTagName = _ref2.innerTagName,
3891
+ outerTagName = _ref2.outerTagName,
3892
+ width = _ref2.width;
3893
+ var instance = _ref3.instance;
3894
+
3895
+ if (process.env.NODE_ENV !== 'production') {
3896
+ if (innerTagName != null || outerTagName != null) {
3897
+ if (devWarningsTagName$1 && !devWarningsTagName$1.has(instance)) {
3898
+ devWarningsTagName$1.add(instance);
3899
+ console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
3900
+ }
3901
+ } // TODO Deprecate direction "horizontal"
3902
+
3903
+
3904
+ var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
3905
+
3906
+ switch (direction) {
3907
+ case 'horizontal':
3908
+ case 'vertical':
3909
+ if (devWarningsDirection && !devWarningsDirection.has(instance)) {
3910
+ devWarningsDirection.add(instance);
3911
+ console.warn('The direction prop should be either "ltr" (default) or "rtl". ' + 'Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.');
3912
+ }
3913
+
3914
+ break;
3915
+
3916
+ case 'ltr':
3917
+ case 'rtl':
3918
+ // Valid values
3919
+ break;
3920
+
3921
+ default:
3922
+ throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
3923
+ }
3924
+
3925
+ switch (layout) {
3926
+ case 'horizontal':
3927
+ case 'vertical':
3928
+ // Valid values
3929
+ break;
3930
+
3931
+ default:
3932
+ throw Error('An invalid "layout" prop has been specified. ' + 'Value should be either "horizontal" or "vertical". ' + ("\"" + layout + "\" was specified."));
3933
+ }
3934
+
3935
+ if (children == null) {
3936
+ throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
3937
+ }
3938
+
3939
+ if (isHorizontal && typeof width !== 'number') {
3940
+ throw Error('An invalid "width" prop has been specified. ' + 'Horizontal lists must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
3941
+ } else if (!isHorizontal && typeof height !== 'number') {
3942
+ throw Error('An invalid "height" prop has been specified. ' + 'Vertical lists must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
3943
+ }
3944
+ }
3945
+ };
3946
+
3947
+ var DEFAULT_ESTIMATED_ITEM_SIZE$1 = 50;
3948
+
3949
+ var getItemMetadata$1 = function getItemMetadata(props, index, instanceProps) {
3950
+ var _ref = props,
3951
+ itemSize = _ref.itemSize;
3952
+ var itemMetadataMap = instanceProps.itemMetadataMap,
3953
+ lastMeasuredIndex = instanceProps.lastMeasuredIndex;
3954
+
3955
+ if (index > lastMeasuredIndex) {
3956
+ var offset = 0;
3957
+
3958
+ if (lastMeasuredIndex >= 0) {
3959
+ var itemMetadata = itemMetadataMap[lastMeasuredIndex];
3960
+ offset = itemMetadata.offset + itemMetadata.size;
3961
+ }
3962
+
3963
+ for (var i = lastMeasuredIndex + 1; i <= index; i++) {
3964
+ var size = itemSize(i);
3965
+ itemMetadataMap[i] = {
3966
+ offset: offset,
3967
+ size: size
3968
+ };
3969
+ offset += size;
3970
+ }
3971
+
3972
+ instanceProps.lastMeasuredIndex = index;
3973
+ }
3974
+
3975
+ return itemMetadataMap[index];
3976
+ };
3977
+
3978
+ var findNearestItem$1 = function findNearestItem(props, instanceProps, offset) {
3979
+ var itemMetadataMap = instanceProps.itemMetadataMap,
3980
+ lastMeasuredIndex = instanceProps.lastMeasuredIndex;
3981
+ var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
3982
+
3983
+ if (lastMeasuredItemOffset >= offset) {
3984
+ // If we've already measured items within this range just use a binary search as it's faster.
3985
+ return findNearestItemBinarySearch$1(props, instanceProps, lastMeasuredIndex, 0, offset);
3986
+ } else {
3987
+ // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
3988
+ // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
3989
+ // The overall complexity for this approach is O(log n).
3990
+ return findNearestItemExponentialSearch$1(props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
3991
+ }
3992
+ };
3993
+
3994
+ var findNearestItemBinarySearch$1 = function findNearestItemBinarySearch(props, instanceProps, high, low, offset) {
3995
+ while (low <= high) {
3996
+ var middle = low + Math.floor((high - low) / 2);
3997
+ var currentOffset = getItemMetadata$1(props, middle, instanceProps).offset;
3998
+
3999
+ if (currentOffset === offset) {
4000
+ return middle;
4001
+ } else if (currentOffset < offset) {
4002
+ low = middle + 1;
4003
+ } else if (currentOffset > offset) {
4004
+ high = middle - 1;
4005
+ }
4006
+ }
4007
+
4008
+ if (low > 0) {
4009
+ return low - 1;
4010
+ } else {
4011
+ return 0;
4012
+ }
4013
+ };
4014
+
4015
+ var findNearestItemExponentialSearch$1 = function findNearestItemExponentialSearch(props, instanceProps, index, offset) {
4016
+ var itemCount = props.itemCount;
4017
+ var interval = 1;
4018
+
4019
+ while (index < itemCount && getItemMetadata$1(props, index, instanceProps).offset < offset) {
4020
+ index += interval;
4021
+ interval *= 2;
4022
+ }
4023
+
4024
+ return findNearestItemBinarySearch$1(props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
4025
+ };
4026
+
4027
+ var getEstimatedTotalSize = function getEstimatedTotalSize(_ref2, _ref3) {
4028
+ var itemCount = _ref2.itemCount;
4029
+ var itemMetadataMap = _ref3.itemMetadataMap,
4030
+ estimatedItemSize = _ref3.estimatedItemSize,
4031
+ lastMeasuredIndex = _ref3.lastMeasuredIndex;
4032
+ var totalSizeOfMeasuredItems = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
4033
+ // https://github.com/bvaughn/react-window/pull/138
4034
+
4035
+ if (lastMeasuredIndex >= itemCount) {
4036
+ lastMeasuredIndex = itemCount - 1;
4037
+ }
4038
+
4039
+ if (lastMeasuredIndex >= 0) {
4040
+ var itemMetadata = itemMetadataMap[lastMeasuredIndex];
4041
+ totalSizeOfMeasuredItems = itemMetadata.offset + itemMetadata.size;
4042
+ }
4043
+
4044
+ var numUnmeasuredItems = itemCount - lastMeasuredIndex - 1;
4045
+ var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedItemSize;
4046
+ return totalSizeOfMeasuredItems + totalSizeOfUnmeasuredItems;
4047
+ };
4048
+
4049
+ var VariableSizeList = /*#__PURE__*/createListComponent({
4050
+ getItemOffset: function getItemOffset(props, index, instanceProps) {
4051
+ return getItemMetadata$1(props, index, instanceProps).offset;
4052
+ },
4053
+ getItemSize: function getItemSize(props, index, instanceProps) {
4054
+ return instanceProps.itemMetadataMap[index].size;
4055
+ },
4056
+ getEstimatedTotalSize: getEstimatedTotalSize,
4057
+ getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
4058
+ var direction = props.direction,
4059
+ height = props.height,
4060
+ layout = props.layout,
4061
+ width = props.width; // TODO Deprecate direction "horizontal"
4062
+
4063
+ var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
4064
+ var size = isHorizontal ? width : height;
4065
+ var itemMetadata = getItemMetadata$1(props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
4066
+ // To ensure it reflects actual measurements instead of just estimates.
4067
+
4068
+ var estimatedTotalSize = getEstimatedTotalSize(props, instanceProps);
4069
+ var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
4070
+ var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size + scrollbarSize);
4071
+
4072
+ if (align === 'smart') {
4073
+ if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
4074
+ align = 'auto';
4075
+ } else {
4076
+ align = 'center';
4077
+ }
4078
+ }
4079
+
4080
+ switch (align) {
4081
+ case 'start':
4082
+ return maxOffset;
4083
+
4084
+ case 'end':
4085
+ return minOffset;
4086
+
4087
+ case 'center':
4088
+ return Math.round(minOffset + (maxOffset - minOffset) / 2);
4089
+
4090
+ case 'auto':
4091
+ default:
4092
+ if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
4093
+ return scrollOffset;
4094
+ } else if (scrollOffset < minOffset) {
4095
+ return minOffset;
4096
+ } else {
4097
+ return maxOffset;
4098
+ }
4099
+
4100
+ }
4101
+ },
4102
+ getStartIndexForOffset: function getStartIndexForOffset(props, offset, instanceProps) {
4103
+ return findNearestItem$1(props, instanceProps, offset);
4104
+ },
4105
+ getStopIndexForStartIndex: function getStopIndexForStartIndex(props, startIndex, scrollOffset, instanceProps) {
4106
+ var direction = props.direction,
4107
+ height = props.height,
4108
+ itemCount = props.itemCount,
4109
+ layout = props.layout,
4110
+ width = props.width; // TODO Deprecate direction "horizontal"
4111
+
4112
+ var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
4113
+ var size = isHorizontal ? width : height;
4114
+ var itemMetadata = getItemMetadata$1(props, startIndex, instanceProps);
4115
+ var maxOffset = scrollOffset + size;
4116
+ var offset = itemMetadata.offset + itemMetadata.size;
4117
+ var stopIndex = startIndex;
4118
+
4119
+ while (stopIndex < itemCount - 1 && offset < maxOffset) {
4120
+ stopIndex++;
4121
+ offset += getItemMetadata$1(props, stopIndex, instanceProps).size;
4122
+ }
4123
+
4124
+ return stopIndex;
4125
+ },
4126
+ initInstanceProps: function initInstanceProps(props, instance) {
4127
+ var _ref4 = props,
4128
+ estimatedItemSize = _ref4.estimatedItemSize;
4129
+ var instanceProps = {
4130
+ itemMetadataMap: {},
4131
+ estimatedItemSize: estimatedItemSize || DEFAULT_ESTIMATED_ITEM_SIZE$1,
4132
+ lastMeasuredIndex: -1
4133
+ };
4134
+
4135
+ instance.resetAfterIndex = function (index, shouldForceUpdate) {
4136
+ if (shouldForceUpdate === void 0) {
4137
+ shouldForceUpdate = true;
4138
+ }
4139
+
4140
+ instanceProps.lastMeasuredIndex = Math.min(instanceProps.lastMeasuredIndex, index - 1); // We could potentially optimize further by only evicting styles after this index,
4141
+ // But since styles are only cached while scrolling is in progress-
4142
+ // It seems an unnecessary optimization.
4143
+ // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
4144
+
4145
+ instance._getItemStyleCache(-1);
4146
+
4147
+ if (shouldForceUpdate) {
4148
+ instance.forceUpdate();
4149
+ }
4150
+ };
4151
+
4152
+ return instanceProps;
4153
+ },
4154
+ shouldResetStyleCacheOnItemSizeChange: false,
4155
+ validateProps: function validateProps(_ref5) {
4156
+ var itemSize = _ref5.itemSize;
4157
+
4158
+ if (process.env.NODE_ENV !== 'production') {
4159
+ if (typeof itemSize !== 'function') {
4160
+ throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
4161
+ }
4162
+ }
4163
+ }
4164
+ });
4165
+
3218
4166
  /* *
3219
4167
  * Licensed under the Apache License, Version 2.0 (the "License");
3220
4168
  * you may not use this file except in compliance with the License.
@@ -3233,23 +4181,54 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
3233
4181
  * */
3234
4182
  var DATE_FORMAT = 'dd/MM/yyyy HH:mm';
3235
4183
  var DATE_FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
3236
-
3237
- /* *
3238
- * Licensed under the Apache License, Version 2.0 (the "License");
3239
- * you may not use this file except in compliance with the License.
3240
- * You may obtain a copy of the License at
3241
- *
3242
- * http://www.apache.org/licenses/LICENSE-2.0
3243
- *
3244
- * Unless required by applicable law or agreed to in writing, software
3245
- * distributed under the License is distributed on an "AS IS" BASIS,
3246
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3247
- * See the License for the specific language governing permissions and
3248
- * limitations under the License.
3249
- *
3250
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3251
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
3252
- * */
4184
+ var DATE_FORMAT_HEADER = 'EEEE, MMMM dd';
4185
+
4186
+ var DEFAULT_DIALOG_HEIGHT = 500;
4187
+ var DEFAULT_ADD_BUTTON_HEIGHT = 80;
4188
+ var DEFAULT_PADDING_TOP = 6;
4189
+ var OBJECT_ITEM_SIZE = 50;
4190
+ var HEADER_ITEM_SIZE = 23;
4191
+ var MIN_HEIGHT_SCROLLABLE_LIST = 90; // Slightly less than 2 rows
4192
+ var useGetRequiredHeights = function useGetRequiredHeights() {
4193
+ var listRef = React__default.useRef(null);
4194
+ // Used to store the height of the list dialog content
4195
+ var _React$useState = React__default.useState(DEFAULT_DIALOG_HEIGHT),
4196
+ _React$useState2 = _slicedToArray(_React$useState, 2),
4197
+ dialogHeight = _React$useState2[0],
4198
+ setDialogHeight = _React$useState2[1];
4199
+ // Used to store the height of the "Add new object" button
4200
+ var _React$useState3 = React__default.useState(DEFAULT_ADD_BUTTON_HEIGHT),
4201
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
4202
+ addButtonHeight = _React$useState4[0],
4203
+ setAddButtonHeight = _React$useState4[1];
4204
+ // Obtain the height of of the list dialog content
4205
+ React__default.useLayoutEffect(function () {
4206
+ var _a;
4207
+ var dialogElement = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
4208
+ (dialogElement === null || dialogElement === void 0 ? void 0 : dialogElement.offsetHeight) && setDialogHeight(dialogElement === null || dialogElement === void 0 ? void 0 : dialogElement.offsetHeight);
4209
+ var observer = new ResizeObserver(function () {
4210
+ var height = getHeight(dialogElement);
4211
+ height && setDialogHeight(height);
4212
+ });
4213
+ observer.observe(dialogElement);
4214
+ return function () {
4215
+ observer.disconnect();
4216
+ };
4217
+ }, [listRef]);
4218
+ // Obtain height of the "Add new object" button
4219
+ React__default.useEffect(function () {
4220
+ var _a, _b;
4221
+ var buttonElement = (_b = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.lastChild;
4222
+ var height = getHeight(buttonElement);
4223
+ height && setAddButtonHeight(height);
4224
+ }, []);
4225
+ var availableSpaceForList = dialogHeight - addButtonHeight - DEFAULT_PADDING_TOP;
4226
+ var listHeight = availableSpaceForList && availableSpaceForList < MIN_HEIGHT_SCROLLABLE_LIST ? MIN_HEIGHT_SCROLLABLE_LIST : availableSpaceForList;
4227
+ return {
4228
+ listRef: listRef,
4229
+ listHeight: listHeight
4230
+ };
4231
+ };
3253
4232
  var NO_OBJECTS_FOUND = 'No objects found';
3254
4233
  var BUTTON_EDIT$1 = 'Edit';
3255
4234
  var BUTTON_DELETE$1 = 'Delete';
@@ -3258,6 +4237,33 @@ var BUTTON_AIRMET = 'AIRMET';
3258
4237
  var BUTTON_SIGMET = 'SIGMET';
3259
4238
  var BUTTON_PUBLIC_WARNING = 'PUBLIC WARNING';
3260
4239
  var MENU_SHARE = 'Share object to';
4240
+ var getListInclHeaders = function getListInclHeaders(objects) {
4241
+ var listInclHeaders = [];
4242
+ var headerList = [];
4243
+ // Construct list incl day headers
4244
+ objects.forEach(function (object, index) {
4245
+ var objectDate = dateUtils.isoStringToDate(object.lastUpdatedTime);
4246
+ var header = dateUtils.dateToString(objectDate, DATE_FORMAT_HEADER, true);
4247
+ var isNewDay = !headerList.find(function (item) {
4248
+ return item === header;
4249
+ });
4250
+ if (isNewDay) {
4251
+ var newLength = headerList.push(header);
4252
+ listInclHeaders.push({
4253
+ isObject: false,
4254
+ index: newLength - 1
4255
+ });
4256
+ }
4257
+ listInclHeaders.push({
4258
+ isObject: true,
4259
+ index: index
4260
+ });
4261
+ });
4262
+ return {
4263
+ listInclHeaders: listInclHeaders,
4264
+ headerList: headerList
4265
+ };
4266
+ };
3261
4267
  var Objects = function Objects(_ref) {
3262
4268
  var objects = _ref.objects,
3263
4269
  onClickObject = _ref.onClickObject,
@@ -3267,40 +4273,60 @@ var Objects = function Objects(_ref) {
3267
4273
  activeObject = _ref.activeObject,
3268
4274
  _ref$isLoading = _ref.isLoading,
3269
4275
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading;
3270
- var headerList = [];
3271
- if (!isLoading && objects.length === 0) {
3272
- return /*#__PURE__*/React__default.createElement(Typography, {
3273
- sx: {
3274
- paddingLeft: '16px',
3275
- paddingTop: '8px'
3276
- },
3277
- variant: "body1"
3278
- }, NO_OBJECTS_FOUND);
3279
- }
3280
- return /*#__PURE__*/React__default.createElement(List, {
4276
+ // Used to store the height of the list dialog content
4277
+ var _useGetRequiredHeight = useGetRequiredHeights(),
4278
+ listRef = _useGetRequiredHeight.listRef,
4279
+ listHeight = _useGetRequiredHeight.listHeight;
4280
+ var _getListInclHeaders = getListInclHeaders(objects),
4281
+ listInclHeaders = _getListInclHeaders.listInclHeaders,
4282
+ headerList = _getListInclHeaders.headerList;
4283
+ var getItemSize = function getItemSize(index) {
4284
+ var item = listInclHeaders[index];
4285
+ if (item.isObject) {
4286
+ return OBJECT_ITEM_SIZE;
4287
+ }
4288
+ return HEADER_ITEM_SIZE;
4289
+ };
4290
+ return /*#__PURE__*/React__default.createElement(Box, {
4291
+ ref: listRef,
3281
4292
  sx: {
3282
- height: 'calc( 100% - 80px )',
3283
- overflow: 'auto'
4293
+ paddingTop: 0.75
3284
4294
  }
3285
- }, objects.map(function (object) {
3286
- var objectDate = dateUtils.isoStringToDate(object.lastUpdatedTime);
3287
- var header = dateUtils.dateToString(objectDate, 'EEEE, MMMM dd', true);
3288
- var isNewDay = !headerList.find(function (item) {
3289
- return item === header;
3290
- });
3291
- if (isNewDay) {
3292
- headerList.push(header);
4295
+ }, !isLoading && objects.length === 0 ? /*#__PURE__*/React__default.createElement(Typography, {
4296
+ sx: {
4297
+ paddingLeft: '16px',
4298
+ paddingTop: '8px'
4299
+ },
4300
+ variant: "body1"
4301
+ }, NO_OBJECTS_FOUND) : /*#__PURE__*/React__default.createElement(VariableSizeList, {
4302
+ height: listHeight,
4303
+ itemCount: listInclHeaders.length,
4304
+ itemSize: getItemSize,
4305
+ width: "100%"
4306
+ }, function (_ref2) {
4307
+ var index = _ref2.index,
4308
+ style = _ref2.style;
4309
+ var listItem = listInclHeaders[index];
4310
+ if (!listItem.isObject) {
4311
+ var header = headerList[listItem.index];
4312
+ return /*#__PURE__*/React__default.createElement(Typography, {
4313
+ style: style,
4314
+ key: listItem.index,
4315
+ sx: {
4316
+ paddingLeft: 2.5,
4317
+ paddingBottom: 0.5,
4318
+ paddingTop: 0.5,
4319
+ opacity: 0.67
4320
+ },
4321
+ variant: "caption"
4322
+ }, header);
3293
4323
  }
3294
- return /*#__PURE__*/React__default.createElement(Fragment, {
3295
- key: object.id
3296
- }, isNewDay && /*#__PURE__*/React__default.createElement(Typography, {
3297
- sx: {
3298
- paddingLeft: 2.5,
3299
- opacity: 0.67
3300
- },
3301
- variant: "caption"
3302
- }, header), /*#__PURE__*/React__default.createElement(ListItem, {
4324
+ var object = objects[listItem.index];
4325
+ var objectDate = dateUtils.isoStringToDate(object.lastUpdatedTime);
4326
+ return /*#__PURE__*/React__default.createElement(ListItem, {
4327
+ style: style,
3303
4328
  disablePadding: true,
4329
+ key: object.id,
3304
4330
  sx: {
3305
4331
  '& .MuiListItemSecondaryAction-root': {
3306
4332
  right: '8px'
@@ -3376,7 +4402,7 @@ var Objects = function Objects(_ref) {
3376
4402
  sx: {
3377
4403
  opacity: 0.67
3378
4404
  }
3379
- }, object.scope === 'global' && 'Global: ', dateUtils.dateToString(objectDate, DATE_FORMAT, true), ' ', "UTC"))))));
4405
+ }, object.scope === 'global' && 'Global: ', dateUtils.dateToString(objectDate, DATE_FORMAT, true), ' ', "UTC")))));
3380
4406
  }));
3381
4407
  };
3382
4408
 
@@ -3389,7 +4415,7 @@ var DEFAULT_OBJECT_MANAGER_POSITION = {
3389
4415
  left: 50
3390
4416
  };
3391
4417
  var DEFAULT_OBJECT_MANAGER_MIN_SIZE = {
3392
- width: 160,
4418
+ width: 200,
3393
4419
  height: 300
3394
4420
  };
3395
4421
  var BUTTON_ADD_OBJECT$1 = 'Add a new object';