@beppla/tapas-ui 1.0.70 → 1.0.71
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/commonjs/Alert/Alert.js +67 -46
- package/commonjs/Alert/Alert.js.map +1 -2
- package/commonjs/AnimatedNavItem/AnimatedNavItem.js +0 -71
- package/commonjs/AnimatedNavItem/AnimatedNavItem.js.map +0 -1
- package/commonjs/AnimatedNavItem/index.js +9 -15
- package/commonjs/BarChart/BarChart.js.map +2 -1
- package/commonjs/Button/Button.js +78 -96
- package/commonjs/Button/Button.js.map +2 -1
- package/commonjs/Button/ButtonGroup.js.map +2 -1
- package/commonjs/Calendar/Calendar.base.js +190 -162
- package/commonjs/Calendar/Calendar.base.js.map +2 -1
- package/commonjs/Calendar/Calendar.js +102 -86
- package/commonjs/Calendar/Calendar.js.map +1 -2
- package/commonjs/Calendar/DaySelector.js +113 -115
- package/commonjs/Calendar/DaySelector.js.map +1 -2
- package/commonjs/Calendar/TimeSelector.js +223 -274
- package/commonjs/Calendar/WeekDaySelector.js.map +1 -2
- package/commonjs/Calendar/helper.js +68 -68
- package/commonjs/Calendar/helper.js.map +1 -2
- package/commonjs/Calendar/types.js +11 -11
- package/commonjs/Calendar/types.js.map +2 -1
- package/commonjs/Card/Card.js +158 -231
- package/commonjs/Card/Card.js.map +1 -1
- package/commonjs/CheckBox/CheckBoxItem.js +36 -86
- package/commonjs/CheckBox/CheckBoxItem.js.map +1 -1
- package/commonjs/CheckBox/GroupCheckBox.js +67 -80
- package/commonjs/CheckBox/GroupCheckBox.js.map +2 -1
- package/commonjs/DashboardCard/DashboardCard.js +94 -74
- package/commonjs/DashboardCard/DashboardCard.js.map +1 -1
- package/commonjs/DataCell/DataCell.js +235 -289
- package/commonjs/DataCell/DataCell.js.map +1 -2
- package/commonjs/DataCell/index.js.map +2 -1
- package/commonjs/DataTable/DataTable.js +144 -70
- package/commonjs/DataTable/DataTable.js.map +1 -2
- package/commonjs/DataTable/index.js.map +1 -2
- package/commonjs/DeviceSelectionModal/DeviceSelectionModal.js +244 -242
- package/commonjs/DeviceSelectionModal/DeviceSelectionModal.js.map +1 -1
- package/commonjs/DraggableFlatList/DraggableFlatList.js +1 -1
- package/commonjs/Dropdown/Dropdown.js +461 -493
- package/commonjs/Dropdown/Dropdown.js.map +1 -2
- package/commonjs/Dropdown/InputDropdown.js +114 -123
- package/commonjs/ExternalLink/ExternalLink.js +58 -50
- package/commonjs/ExternalLink/ExternalLink.js.map +1 -2
- package/commonjs/Gantt/helper.js.map +1 -2
- package/commonjs/Grid/Grid.base.js +401 -336
- package/commonjs/Grid/Grid.base.js.map +2 -1
- package/commonjs/Grid/VariableSizeGrid.js +113 -120
- package/commonjs/Grid/VariableSizeGrid.js.map +1 -2
- package/commonjs/Grid/helper.js +16 -11
- package/commonjs/Header/Header.js +177 -166
- package/commonjs/Header/Header.js.map +1 -2
- package/commonjs/HelloWave/HelloWave.js +53 -46
- package/commonjs/HelloWave/HelloWave.js.map +2 -1
- package/commonjs/Icons/TapasIcon.js +100 -99
- package/commonjs/Icons/TapasIcon.js.map +2 -1
- package/commonjs/Icons/TapasIconExpo.js +94 -101
- package/commonjs/Icons/smartFontLoader.js +222 -266
- package/commonjs/Icons/smartFontLoader.js.map +1 -2
- package/commonjs/Image/Image.js +106 -96
- package/commonjs/Image/Image.js.map +1 -2
- package/commonjs/Image/PreviewImg.js.map +2 -1
- package/commonjs/Layout/DrawerContext.js +35 -49
- package/commonjs/Layout/DrawerContext.js.map +2 -1
- package/commonjs/Layout/Layout.js.map +1 -2
- package/commonjs/Layout/ToastContext.js +46 -34
- package/commonjs/Layout/ToastContext.js.map +1 -2
- package/commonjs/Layout/index.js +38 -34
- package/commonjs/Layout/index.js.map +1 -2
- package/commonjs/LineChart/index.js +3 -4
- package/commonjs/ListItem/ListItem.js +108 -80
- package/commonjs/ListItem/ListItem.js.map +1 -2
- package/commonjs/MultiSelector/MultiSelector.js +225 -250
- package/commonjs/MultiSelector/MultiSelector.js.map +1 -2
- package/commonjs/Navigation/Navigation.js +117 -114
- package/commonjs/Navigation/Navigation.js.map +1 -2
- package/commonjs/Notification/Notification.js +66 -135
- package/commonjs/Notification/Notification.js.map +1 -1
- package/commonjs/Notification/index.js.map +1 -2
- package/commonjs/NumericInput/NumericInput.js +85 -71
- package/commonjs/NumericInput/NumericInput.js.map +1 -2
- package/commonjs/Overlay/Overlay.js +45 -24
- package/commonjs/Overlay/Overlay.js.map +1 -1
- package/commonjs/Popover/Popover.js +137 -112
- package/commonjs/Popover/Popover.js.map +2 -1
- package/commonjs/Progress/Progress.js +48 -54
- package/commonjs/Progress/Progress.js.map +2 -1
- package/commonjs/Quantity/Quantity.js +70 -0
- package/commonjs/Quantity/Quantity.js.map +1 -0
- package/commonjs/RadioButton/RadioButton.js +94 -46
- package/commonjs/RadioButton/RadioButton.js.map +1 -1
- package/commonjs/ReasonModal/index.js +14 -9
- package/commonjs/ReasonModal/index.js.map +2 -1
- package/commonjs/SheetTitle/SheetTitle.js +34 -31
- package/commonjs/SheetTitle/SheetTitle.js.map +1 -1
- package/commonjs/Shell/Shell.js +92 -84
- package/commonjs/Shell/Shell.js.map +1 -2
- package/commonjs/Shell/styles.js +3 -3
- package/commonjs/Shell/styles.js.map +2 -1
- package/commonjs/Shell/types.js.map +2 -1
- package/commonjs/StatisticCard/StatisticCard.js +47 -41
- package/commonjs/Status/Status.js +35 -31
- package/commonjs/Status/Status.js.map +2 -1
- package/commonjs/Steps/Steps.js +40 -41
- package/commonjs/Steps/Steps.js.map +1 -1
- package/commonjs/TabTitle/TabTitle.js +54 -48
- package/commonjs/TabTitle/index.js +1 -0
- package/commonjs/TabTitle/index.js.map +1 -0
- package/commonjs/Tag/Tag.js +88 -34
- package/commonjs/Tag/Tag.js.map +1 -1
- package/commonjs/Task/Task.js +112 -201
- package/commonjs/Task/Task.js.map +1 -2
- package/commonjs/Task/type.js +4 -4
- package/commonjs/Text/Text.js +96 -56
- package/commonjs/Text/Text.js.map +1 -1
- package/commonjs/Theme/ThemeProvider.js +16 -18
- package/commonjs/Timeline/Timeline.js +0 -23
- package/commonjs/Timeline/Timeline.js.map +0 -1
- package/commonjs/Toast/Toast.js +83 -62
- package/commonjs/Toast/Toast.js.map +1 -2
- package/commonjs/UserSwitcher/index.js +8 -14
- package/commonjs/UserSwitcher/index.js.map +1 -2
- package/commonjs/common.js +5 -4
- package/commonjs/common.js.map +2 -1
- package/commonjs/index.js +336 -426
- package/module/AnimatedNavItem/AnimatedNavItem.js +124 -159
- package/module/AnimatedNavItem/index.js +3 -7
- package/module/AnimatedNavItem/index.js.map +2 -1
- package/module/BarChart/index.js.map +1 -2
- package/module/Button/Button.js +71 -80
- package/module/Button/Button.js.map +2 -1
- package/module/Button/ButtonGroup.js +129 -120
- package/module/Button/ButtonGroup.js.map +2 -1
- package/module/Calendar/Calendar.base.js +226 -149
- package/module/Calendar/Calendar.base.js.map +2 -1
- package/module/Calendar/Calendar.js +76 -80
- package/module/Calendar/Calendar.js.map +1 -2
- package/module/Calendar/ConcreteTimeSelector.js.map +1 -2
- package/module/Calendar/CustomRange.js.map +2 -1
- package/module/Calendar/DaySelector.js +95 -118
- package/module/Calendar/TimeSelector.js.map +2 -1
- package/module/Calendar/WeekDaySelector.js.map +1 -2
- package/module/Calendar/helper.js +74 -74
- package/module/Calendar/helper.js.map +2 -1
- package/module/Calendar/local.js +7 -7
- package/module/Calendar/local.js.map +1 -2
- package/module/Calendar/types.js +13 -13
- package/module/CheckBox/CheckBox.js +93 -89
- package/module/CheckBox/CheckBox.js.map +1 -2
- package/module/CheckBox/CheckBoxItem.js +69 -84
- package/module/CheckBox/CheckBoxItem.js.map +1 -1
- package/module/CheckBox/GroupCheckBox.js +66 -76
- package/module/CheckBox/GroupCheckBox.js.map +1 -2
- package/module/CircularProgress/CircularProgress.js +22 -0
- package/module/CircularProgress/CircularProgress.js.map +1 -0
- package/module/Collapsible/Collapsible.js +54 -64
- package/module/Collapsible/Collapsible.js.map +1 -2
- package/module/DataCell/DataCell.js +311 -224
- package/module/DataCell/index.js +4 -3
- package/module/DataCell/index.js.map +1 -2
- package/module/DataTable/index.js +2 -4
- package/module/DataTable/index.js.map +2 -1
- package/module/DeviceSelectionModal/DeviceSelectionModal.js +178 -241
- package/module/DeviceSelectionModal/DeviceSelectionModal.js.map +1 -2
- package/module/DraggableFlatList/DraggableFlatList.js +0 -9
- package/module/DraggableFlatList/DraggableFlatList.js.map +0 -1
- package/module/Drawer/Drawer.js +167 -139
- package/module/Drawer/Drawer.js.map +2 -1
- package/module/Dropdown/CustomDropdown.js +56 -0
- package/module/Dropdown/CustomDropdown.js.map +1 -0
- package/module/Dropdown/InputDropdown.js +116 -134
- package/module/Dropdown/InputDropdown.js.map +1 -2
- package/module/ExternalLink/ExternalLink.js +150 -0
- package/module/ExternalLink/ExternalLink.js.map +1 -0
- package/module/Gantt/Accessories.js +183 -124
- package/module/Gantt/Gantt.js +139 -152
- package/module/Gantt/Gantt.js.map +1 -2
- package/module/Gantt/types.js +4 -8
- package/module/Gantt/types.js.map +2 -1
- package/module/Grid/FixedSizeGrid.js +86 -80
- package/module/Grid/FixedSizeGrid.js.map +2 -1
- package/module/Grid/Grid.base.js +401 -339
- package/module/Grid/Grid.base.js.map +2 -1
- package/module/Grid/StaticFixedSizeGrid.js +192 -255
- package/module/Grid/VariableSizeGrid.js +121 -118
- package/module/Grid/VariableSizeGrid.js.map +2 -1
- package/module/Grid/helper.js.map +1 -2
- package/module/Grid/timer.js +14 -16
- package/module/Grid/timer.js.map +2 -1
- package/module/Header/Header.js +167 -183
- package/module/Header/Header.js.map +1 -2
- package/module/IconText/IconText.js +63 -88
- package/module/IconText/IconText.js.map +1 -2
- package/module/Icons/TapasIcon.js +120 -96
- package/module/Icons/TapasIcon.js.map +2 -1
- package/module/Icons/TapasIconExpo.js +78 -98
- package/module/Icons/TapasIconExpo.js.map +1 -2
- package/module/Icons/fontLoader.js +213 -182
- package/module/Icons/index.js +9 -10
- package/module/Icons/smartFontLoader.js.map +1 -2
- package/module/Layout/Layout.js +100 -100
- package/module/Layout/ToastContext.js +27 -15
- package/module/Layout/ToastContext.js.map +2 -1
- package/module/Layout/index.js.map +1 -2
- package/module/LineChart/LineChart.js +121 -157
- package/module/LineChart/LineChart.js.map +2 -1
- package/module/MultiSelector/MultiSelector.js.map +1 -2
- package/module/Notification/Notification.js +101 -105
- package/module/Notification/Notification.js.map +1 -2
- package/module/Notification/index.js +2 -3
- package/module/Notification/index.js.map +2 -1
- package/module/NumericInput/NumericInput.js +0 -54
- package/module/Pagination/Pagination.js +72 -0
- package/module/Pagination/Pagination.js.map +1 -0
- package/module/PieChart/PieChart.js +76 -101
- package/module/PieChart/index.js.map +0 -1
- package/module/Popover/Popover.js +97 -125
- package/module/Popover/Popover.js.map +1 -1
- package/module/Progress/Progress.js +51 -57
- package/module/Progress/Progress.js.map +1 -2
- package/module/Quantity/Quantity.js +112 -129
- package/module/Quantity/Quantity.js.map +1 -2
- package/module/Quantity/index.js +3 -2
- package/module/Quantity/index.js.map +1 -2
- package/module/ReasonModal/ReasonModal.js.map +2 -1
- package/module/ReasonModal/index.js +5 -3
- package/module/ReasonModal/index.js.map +1 -2
- package/module/ScanButton/ScanButton.js +77 -53
- package/module/ScanButton/ScanButton.js.map +2 -1
- package/module/SearchInput/SearchInput.js +83 -93
- package/module/SearchInput/SearchInput.js.map +1 -2
- package/module/SheetTitle/SheetTitle.js +29 -39
- package/module/SheetTitle/SheetTitle.js.map +2 -1
- package/module/Shell/Shell.js +92 -79
- package/module/Shell/Shell.js.map +2 -1
- package/module/Shell/styles.js +8 -8
- package/module/Shell/styles.js.map +2 -1
- package/module/Shell/types.js +4 -2
- package/module/Shell/types.js.map +1 -2
- package/module/StatisticCard/StatisticCard.js +48 -79
- package/module/StatisticCard/StatisticCard.js.map +1 -2
- package/module/Status/Status.js.map +0 -1
- package/module/Steps/Steps.js +36 -41
- package/module/Steps/Steps.js.map +1 -2
- package/module/TabTitle/TabTitle.js.map +2 -1
- package/module/TableColumnHeader/TableColumnHeader.js +126 -153
- package/module/TableColumnHeader/index.js +8 -3
- package/module/TableColumnHeader/index.js.map +1 -2
- package/module/Tag/Tag.js +72 -87
- package/module/Tag/Tag.js.map +1 -2
- package/module/Task/Task.js +207 -113
- package/module/Task/Task.js.map +2 -1
- package/module/Task/type.js +8 -4
- package/module/Task/type.js.map +2 -1
- package/module/Text/Text.js +70 -80
- package/module/Text/Text.js.map +2 -1
- package/module/Theme/ThemeProvider.js.map +1 -2
- package/module/Toast/Toast.js +66 -77
- package/module/Toast/Toast.js.map +1 -2
- package/module/UserSwitcher/UserSwitcher.js +130 -171
- package/module/UserSwitcher/UserSwitcher.js.map +1 -2
- package/module/index.js +120 -131
- package/module/index.js.map +2 -1
- package/package.json +1 -1
|
@@ -1,61 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __extends = void 0 && (void 0).__extends || function () {
|
|
4
|
-
var extendStatics = function (d, b) {
|
|
5
|
-
extendStatics = Object.setPrototypeOf || {
|
|
6
|
-
__proto__: []
|
|
7
|
-
} instanceof Array && function (d, b) {
|
|
8
|
-
d.__proto__ = b;
|
|
9
|
-
} || function (d, b) {
|
|
10
|
-
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
11
|
-
};
|
|
12
|
-
return extendStatics(d, b);
|
|
13
|
-
};
|
|
14
|
-
return function (d, b) {
|
|
15
|
-
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
-
extendStatics(d, b);
|
|
17
|
-
function __() {
|
|
18
|
-
this.constructor = d;
|
|
19
|
-
}
|
|
20
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
|
-
};
|
|
22
|
-
}();
|
|
23
|
-
var __assign = void 0 && (void 0).__assign || function () {
|
|
24
|
-
__assign = Object.assign || function (t) {
|
|
25
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26
|
-
s = arguments[i];
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
28
|
-
}
|
|
29
|
-
return t;
|
|
30
|
-
};
|
|
31
|
-
return __assign.apply(this, arguments);
|
|
32
|
-
};
|
|
33
|
-
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
34
|
-
return mod && mod.__esModule ? mod : {
|
|
35
|
-
"default": mod
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
3
|
Object.defineProperty(exports, "__esModule", {
|
|
39
4
|
value: true
|
|
40
5
|
});
|
|
41
6
|
exports.default = createGridComponent;
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
|
|
7
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _timer = require("./timer");
|
|
10
|
+
var _helper = require("./helper");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
|
+
/* eslint-disable no-console */
|
|
14
|
+
|
|
15
|
+
const IS_SCROLLING_DEBOUNCE_INTERVAL = 150;
|
|
16
|
+
|
|
47
17
|
// @ts-ignore
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
18
|
+
const defaultItemKey = ({
|
|
19
|
+
columnIndex,
|
|
20
|
+
data: _data,
|
|
21
|
+
rowIndex
|
|
22
|
+
}) => `${rowIndex}:${columnIndex}`;
|
|
54
23
|
// In DEV mode, this Set helps us only log a warning once per component instance.
|
|
55
24
|
// This avoids spamming the console every time a render happens.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
25
|
+
let devWarningsOverscanCount = null;
|
|
26
|
+
let devWarningsOverscanRowsColumnsCount = null;
|
|
27
|
+
let devWarningsTagName = null;
|
|
59
28
|
if (process.env.NODE_ENV !== 'production') {
|
|
60
29
|
if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
|
|
61
30
|
devWarningsOverscanCount = new WeakSet();
|
|
@@ -63,175 +32,63 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
63
32
|
devWarningsTagName = new WeakSet();
|
|
64
33
|
}
|
|
65
34
|
}
|
|
66
|
-
function createGridComponent(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
|
|
35
|
+
function createGridComponent({
|
|
36
|
+
getColumnOffset,
|
|
37
|
+
getColumnStartIndexForOffset,
|
|
38
|
+
getColumnStopIndexForStartIndex,
|
|
39
|
+
getColumnWidth,
|
|
40
|
+
getEstimatedTotalHeight,
|
|
41
|
+
getEstimatedTotalWidth,
|
|
42
|
+
getOffsetForColumnAndAlignment,
|
|
43
|
+
getOffsetForRowAndAlignment,
|
|
44
|
+
getRowHeight,
|
|
45
|
+
getRowOffset,
|
|
46
|
+
getRowStartIndexForOffset,
|
|
47
|
+
getRowStopIndexForStartIndex,
|
|
48
|
+
initInstanceProps,
|
|
49
|
+
shouldResetStyleCacheOnItemSizeChange,
|
|
50
|
+
validateProps
|
|
51
|
+
}) {
|
|
52
|
+
return class Grid extends _react.PureComponent {
|
|
53
|
+
_instanceProps = initInstanceProps(this.props, this);
|
|
54
|
+
_resetIsScrollingTimeoutId = null;
|
|
55
|
+
static defaultProps = {
|
|
56
|
+
direction: 'ltr',
|
|
57
|
+
itemData: undefined,
|
|
58
|
+
useIsScrolling: false
|
|
59
|
+
};
|
|
60
|
+
state = {
|
|
61
|
+
instance: this,
|
|
62
|
+
isScrolling: false,
|
|
63
|
+
horizontalScrollDirection: 'forward',
|
|
64
|
+
scrollLeft: typeof this.props.initialScrollLeft === 'number' ? this.props.initialScrollLeft : 0,
|
|
65
|
+
scrollTop: typeof this.props.initialScrollTop === 'number' ? this.props.initialScrollTop : 0,
|
|
66
|
+
scrollUpdateWasRequested: false,
|
|
67
|
+
verticalScrollDirection: 'forward'
|
|
68
|
+
};
|
|
69
|
+
|
|
85
70
|
// Always use explicit constructor for React components.
|
|
86
71
|
// It produces less code after transpilation. (#26)
|
|
87
72
|
// eslint-disable-next-line no-useless-constructor
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_this._instanceProps = initInstanceProps(_this.props, _this);
|
|
91
|
-
_this._resetIsScrollingTimeoutId = null;
|
|
92
|
-
_this.state = {
|
|
93
|
-
instance: _this,
|
|
94
|
-
isScrolling: false,
|
|
95
|
-
horizontalScrollDirection: 'forward',
|
|
96
|
-
scrollLeft: typeof _this.props.initialScrollLeft === 'number' ? _this.props.initialScrollLeft : 0,
|
|
97
|
-
scrollTop: typeof _this.props.initialScrollTop === 'number' ? _this.props.initialScrollTop : 0,
|
|
98
|
-
scrollUpdateWasRequested: false,
|
|
99
|
-
verticalScrollDirection: 'forward'
|
|
100
|
-
};
|
|
101
|
-
_this._outerRefSetter = function (ref) {
|
|
102
|
-
var outerRef = _this.props.outerRef;
|
|
103
|
-
_this._outerRef = ref;
|
|
104
|
-
if (typeof outerRef === 'function') {
|
|
105
|
-
outerRef(ref);
|
|
106
|
-
} else if (outerRef != null && typeof outerRef === 'object' && Object.prototype.hasOwnProperty.call(outerRef, 'current')) {
|
|
107
|
-
outerRef.current = ref;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
_this._onScroll = function (event) {
|
|
111
|
-
var _a = event.currentTarget,
|
|
112
|
-
clientHeight = _a.clientHeight,
|
|
113
|
-
clientWidth = _a.clientWidth,
|
|
114
|
-
scrollLeft = _a.scrollLeft,
|
|
115
|
-
scrollTop = _a.scrollTop,
|
|
116
|
-
scrollHeight = _a.scrollHeight,
|
|
117
|
-
scrollWidth = _a.scrollWidth;
|
|
118
|
-
_this.setState(function (prevState) {
|
|
119
|
-
if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
|
|
120
|
-
// Scroll position may have been updated by cDM/cDU,
|
|
121
|
-
// In which case we don't need to trigger another render,
|
|
122
|
-
// And we don't want to update state.isScrolling.
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
var direction = _this.props.direction;
|
|
126
|
-
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
|
|
127
|
-
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
|
|
128
|
-
// It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
|
|
129
|
-
// So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
|
|
130
|
-
var calculatedScrollLeft = scrollLeft;
|
|
131
|
-
if (direction === 'rtl') {
|
|
132
|
-
switch ((0, helper_1.getRTLOffsetType)()) {
|
|
133
|
-
case 'negative':
|
|
134
|
-
calculatedScrollLeft = -scrollLeft;
|
|
135
|
-
break;
|
|
136
|
-
case 'positive-descending':
|
|
137
|
-
calculatedScrollLeft = scrollWidth - clientWidth - scrollLeft;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
// Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
|
|
142
|
-
calculatedScrollLeft = Math.max(0, Math.min(calculatedScrollLeft, scrollWidth - clientWidth));
|
|
143
|
-
var calculatedScrollTop = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
|
|
144
|
-
return {
|
|
145
|
-
isScrolling: true,
|
|
146
|
-
horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
|
|
147
|
-
scrollLeft: calculatedScrollLeft,
|
|
148
|
-
scrollTop: calculatedScrollTop,
|
|
149
|
-
verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward',
|
|
150
|
-
scrollUpdateWasRequested: false
|
|
151
|
-
};
|
|
152
|
-
}, _this._resetIsScrollingDebounced);
|
|
153
|
-
};
|
|
154
|
-
_this._getItemStyle = function (rowIndex, columnIndex) {
|
|
155
|
-
var _a = _this.props,
|
|
156
|
-
columnWidth = _a.columnWidth,
|
|
157
|
-
direction = _a.direction,
|
|
158
|
-
rowHeight = _a.rowHeight;
|
|
159
|
-
var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && columnWidth, shouldResetStyleCacheOnItemSizeChange && direction, shouldResetStyleCacheOnItemSizeChange && rowHeight);
|
|
160
|
-
var key = "".concat(rowIndex, ":").concat(columnIndex);
|
|
161
|
-
var style;
|
|
162
|
-
if (Object.prototype.hasOwnProperty.call(itemStyleCache, key)) {
|
|
163
|
-
style = itemStyleCache[key];
|
|
164
|
-
} else {
|
|
165
|
-
var offset = getColumnOffset(_this.props, columnIndex, _this._instanceProps);
|
|
166
|
-
var isRtl = direction === 'rtl';
|
|
167
|
-
itemStyleCache[key] = style = {
|
|
168
|
-
position: 'absolute',
|
|
169
|
-
left: isRtl ? undefined : offset,
|
|
170
|
-
right: isRtl ? offset : undefined,
|
|
171
|
-
top: getRowOffset(_this.props, rowIndex, _this._instanceProps),
|
|
172
|
-
height: getRowHeight(_this.props, rowIndex, _this._instanceProps),
|
|
173
|
-
width: getColumnWidth(_this.props, columnIndex, _this._instanceProps)
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return style || {};
|
|
177
|
-
};
|
|
178
|
-
_this._callOnScroll = (0, memoize_one_1.default)(function (scrollLeft, scrollTop, horizontalScrollDirection, verticalScrollDirection, scrollUpdateWasRequested) {
|
|
179
|
-
return _this.props.onScroll({
|
|
180
|
-
horizontalScrollDirection: horizontalScrollDirection,
|
|
181
|
-
scrollLeft: scrollLeft,
|
|
182
|
-
scrollTop: scrollTop,
|
|
183
|
-
verticalScrollDirection: verticalScrollDirection,
|
|
184
|
-
scrollUpdateWasRequested: scrollUpdateWasRequested
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
_this._callOnItemsRendered = (0, memoize_one_1.default)(function (overscanColumnStartIndex, overscanColumnStopIndex, overscanRowStartIndex, overscanRowStopIndex, visibleColumnStartIndex, visibleColumnStopIndex, visibleRowStartIndex, visibleRowStopIndex) {
|
|
188
|
-
return _this.props.onItemsRendered({
|
|
189
|
-
overscanColumnStartIndex: overscanColumnStartIndex,
|
|
190
|
-
overscanColumnStopIndex: overscanColumnStopIndex,
|
|
191
|
-
overscanRowStartIndex: overscanRowStartIndex,
|
|
192
|
-
overscanRowStopIndex: overscanRowStopIndex,
|
|
193
|
-
visibleColumnStartIndex: visibleColumnStartIndex,
|
|
194
|
-
visibleColumnStopIndex: visibleColumnStopIndex,
|
|
195
|
-
visibleRowStartIndex: visibleRowStartIndex,
|
|
196
|
-
visibleRowStopIndex: visibleRowStopIndex
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
_this._resetIsScrollingDebounced = function () {
|
|
200
|
-
if (_this._resetIsScrollingTimeoutId !== null) {
|
|
201
|
-
(0, timer_1.cancelTimeout)(_this._resetIsScrollingTimeoutId);
|
|
202
|
-
}
|
|
203
|
-
_this._resetIsScrollingTimeoutId = (0, timer_1.requestTimeout)(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL);
|
|
204
|
-
};
|
|
205
|
-
_this._resetIsScrolling = function () {
|
|
206
|
-
_this._resetIsScrollingTimeoutId = null;
|
|
207
|
-
_this.setState({
|
|
208
|
-
isScrolling: false
|
|
209
|
-
}, function () {
|
|
210
|
-
// Clear style cache after state update has been committed.
|
|
211
|
-
// This way we don't break pure sCU for items that don't use isScrolling param.
|
|
212
|
-
_this._getItemStyleCache(-1);
|
|
213
|
-
});
|
|
214
|
-
};
|
|
215
|
-
_this._getItemStyleCache = (0, memoize_one_1.default)(function (_, __, ___) {
|
|
216
|
-
return {};
|
|
217
|
-
});
|
|
218
|
-
return _this;
|
|
73
|
+
constructor(props) {
|
|
74
|
+
super(props);
|
|
219
75
|
}
|
|
220
|
-
|
|
76
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
221
77
|
validateSharedProps(nextProps, prevState);
|
|
222
78
|
validateProps(nextProps);
|
|
223
79
|
return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
80
|
+
}
|
|
81
|
+
scrollTo({
|
|
82
|
+
scrollLeft,
|
|
83
|
+
scrollTop
|
|
84
|
+
}) {
|
|
228
85
|
if (scrollLeft !== undefined) {
|
|
229
86
|
scrollLeft = Math.max(0, scrollLeft);
|
|
230
87
|
}
|
|
231
88
|
if (scrollTop !== undefined) {
|
|
232
89
|
scrollTop = Math.max(0, scrollTop);
|
|
233
90
|
}
|
|
234
|
-
this.setState(
|
|
91
|
+
this.setState(prevState => {
|
|
235
92
|
if (scrollLeft === undefined) {
|
|
236
93
|
scrollLeft = prevState.scrollLeft;
|
|
237
94
|
}
|
|
@@ -243,51 +100,55 @@ function createGridComponent(_a) {
|
|
|
243
100
|
}
|
|
244
101
|
return {
|
|
245
102
|
horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
|
|
246
|
-
scrollLeft
|
|
247
|
-
scrollTop
|
|
103
|
+
scrollLeft,
|
|
104
|
+
scrollTop,
|
|
248
105
|
scrollUpdateWasRequested: true,
|
|
249
106
|
verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward'
|
|
250
107
|
};
|
|
251
108
|
}, this._resetIsScrollingDebounced);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
columnCount
|
|
260
|
-
height
|
|
261
|
-
rowCount
|
|
262
|
-
width
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
109
|
+
}
|
|
110
|
+
scrollToItem({
|
|
111
|
+
align = 'auto',
|
|
112
|
+
columnIndex,
|
|
113
|
+
rowIndex
|
|
114
|
+
}) {
|
|
115
|
+
const {
|
|
116
|
+
columnCount,
|
|
117
|
+
height,
|
|
118
|
+
rowCount,
|
|
119
|
+
width
|
|
120
|
+
} = this.props;
|
|
121
|
+
const {
|
|
122
|
+
scrollLeft,
|
|
123
|
+
scrollTop
|
|
124
|
+
} = this.state;
|
|
125
|
+
const scrollbarSize = (0, _helper.getScrollbarSize)();
|
|
267
126
|
if (columnIndex !== undefined) {
|
|
268
127
|
columnIndex = Math.max(0, Math.min(columnIndex, columnCount - 1));
|
|
269
128
|
}
|
|
270
129
|
if (rowIndex !== undefined) {
|
|
271
130
|
rowIndex = Math.max(0, Math.min(rowIndex, rowCount - 1));
|
|
272
131
|
}
|
|
273
|
-
|
|
274
|
-
|
|
132
|
+
const estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
|
|
133
|
+
const estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps);
|
|
134
|
+
|
|
275
135
|
// The scrollbar size should be considered when scrolling an item into view,
|
|
276
136
|
// to ensure it's fully visible.
|
|
277
137
|
// But we only need to account for its size when it's actually visible.
|
|
278
|
-
|
|
279
|
-
|
|
138
|
+
const horizontalScrollbarSize = estimatedTotalWidth > width ? scrollbarSize : 0;
|
|
139
|
+
const verticalScrollbarSize = estimatedTotalHeight > height ? scrollbarSize : 0;
|
|
280
140
|
this.scrollTo({
|
|
281
141
|
scrollLeft: columnIndex !== undefined ? getOffsetForColumnAndAlignment(this.props, columnIndex, align, scrollLeft, this._instanceProps, verticalScrollbarSize) : scrollLeft,
|
|
282
142
|
scrollTop: rowIndex !== undefined ? getOffsetForRowAndAlignment(this.props, rowIndex, align, scrollTop, this._instanceProps, horizontalScrollbarSize) : scrollTop
|
|
283
143
|
});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
initialScrollLeft
|
|
288
|
-
initialScrollTop
|
|
144
|
+
}
|
|
145
|
+
componentDidMount() {
|
|
146
|
+
const {
|
|
147
|
+
initialScrollLeft,
|
|
148
|
+
initialScrollTop
|
|
149
|
+
} = this.props;
|
|
289
150
|
if (this._outerRef != null) {
|
|
290
|
-
|
|
151
|
+
const outerRef = this._outerRef;
|
|
291
152
|
if (typeof initialScrollLeft === 'number') {
|
|
292
153
|
outerRef.scrollLeft = initialScrollLeft;
|
|
293
154
|
}
|
|
@@ -296,20 +157,23 @@ function createGridComponent(_a) {
|
|
|
296
157
|
}
|
|
297
158
|
}
|
|
298
159
|
this._callPropsCallbacks();
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
160
|
+
}
|
|
161
|
+
componentDidUpdate() {
|
|
162
|
+
const {
|
|
163
|
+
direction
|
|
164
|
+
} = this.props;
|
|
165
|
+
const {
|
|
166
|
+
scrollLeft,
|
|
167
|
+
scrollTop,
|
|
168
|
+
scrollUpdateWasRequested
|
|
169
|
+
} = this.state;
|
|
306
170
|
if (scrollUpdateWasRequested && this._outerRef != null) {
|
|
307
171
|
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
|
|
308
172
|
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
|
|
309
173
|
// So we need to determine which browser behavior we're dealing with, and mimic it.
|
|
310
|
-
|
|
174
|
+
const outerRef = this._outerRef;
|
|
311
175
|
if (direction === 'rtl') {
|
|
312
|
-
switch ((0,
|
|
176
|
+
switch ((0, _helper.getRTLOffsetType)()) {
|
|
313
177
|
case 'negative':
|
|
314
178
|
outerRef.scrollLeft = -scrollLeft;
|
|
315
179
|
break;
|
|
@@ -318,8 +182,10 @@ function createGridComponent(_a) {
|
|
|
318
182
|
break;
|
|
319
183
|
default:
|
|
320
184
|
{
|
|
321
|
-
|
|
322
|
-
|
|
185
|
+
const {
|
|
186
|
+
clientWidth,
|
|
187
|
+
scrollWidth
|
|
188
|
+
} = outerRef;
|
|
323
189
|
outerRef.scrollLeft = scrollWidth - clientWidth - scrollLeft;
|
|
324
190
|
break;
|
|
325
191
|
}
|
|
@@ -330,80 +196,81 @@ function createGridComponent(_a) {
|
|
|
330
196
|
outerRef.scrollTop = Math.max(0, scrollTop);
|
|
331
197
|
}
|
|
332
198
|
this._callPropsCallbacks();
|
|
333
|
-
}
|
|
334
|
-
|
|
199
|
+
}
|
|
200
|
+
componentWillUnmount() {
|
|
335
201
|
if (this._resetIsScrollingTimeoutId !== null) {
|
|
336
|
-
(0,
|
|
202
|
+
(0, _timer.cancelTimeout)(this._resetIsScrollingTimeoutId);
|
|
337
203
|
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
children
|
|
342
|
-
className
|
|
343
|
-
columnCount
|
|
344
|
-
direction
|
|
345
|
-
height
|
|
346
|
-
innerRef
|
|
347
|
-
innerElementType
|
|
348
|
-
innerTagName
|
|
349
|
-
itemData
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
rowStopIndex = _e[1];
|
|
366
|
-
var items = [];
|
|
204
|
+
}
|
|
205
|
+
render() {
|
|
206
|
+
const {
|
|
207
|
+
children,
|
|
208
|
+
className,
|
|
209
|
+
columnCount,
|
|
210
|
+
direction,
|
|
211
|
+
height,
|
|
212
|
+
innerRef,
|
|
213
|
+
innerElementType,
|
|
214
|
+
innerTagName,
|
|
215
|
+
itemData,
|
|
216
|
+
itemKey = defaultItemKey,
|
|
217
|
+
outerElementType,
|
|
218
|
+
outerTagName,
|
|
219
|
+
rowCount,
|
|
220
|
+
style,
|
|
221
|
+
testID,
|
|
222
|
+
useIsScrolling,
|
|
223
|
+
width
|
|
224
|
+
} = this.props;
|
|
225
|
+
const {
|
|
226
|
+
isScrolling
|
|
227
|
+
} = this.state;
|
|
228
|
+
const [columnStartIndex, columnStopIndex] = this._getHorizontalRangeToRender();
|
|
229
|
+
const [rowStartIndex, rowStopIndex] = this._getVerticalRangeToRender();
|
|
230
|
+
const items = [];
|
|
367
231
|
if (columnCount > 0 && rowCount) {
|
|
368
|
-
for (
|
|
369
|
-
for (
|
|
370
|
-
items.push((0,
|
|
371
|
-
columnIndex
|
|
232
|
+
for (let rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
|
|
233
|
+
for (let columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) {
|
|
234
|
+
items.push(/*#__PURE__*/(0, _react.createElement)(children, {
|
|
235
|
+
columnIndex,
|
|
372
236
|
data: itemData,
|
|
373
237
|
isScrolling: useIsScrolling ? isScrolling : undefined,
|
|
374
238
|
key: itemKey({
|
|
375
|
-
columnIndex
|
|
239
|
+
columnIndex,
|
|
376
240
|
data: itemData,
|
|
377
|
-
rowIndex
|
|
241
|
+
rowIndex
|
|
378
242
|
}),
|
|
379
|
-
rowIndex
|
|
243
|
+
rowIndex,
|
|
380
244
|
style: this._getItemStyle(rowIndex, columnIndex)
|
|
381
245
|
}));
|
|
382
246
|
}
|
|
383
247
|
}
|
|
384
248
|
}
|
|
249
|
+
|
|
385
250
|
// Read this value AFTER items have been created,
|
|
386
251
|
// So their actual sizes (if variable) are taken into consideration.
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
className
|
|
252
|
+
const estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
|
|
253
|
+
const estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps);
|
|
254
|
+
const outerRefSetter = {
|
|
255
|
+
className,
|
|
391
256
|
onScroll: this._onScroll,
|
|
392
257
|
ref: this._outerRefSetter,
|
|
393
|
-
style:
|
|
258
|
+
style: {
|
|
394
259
|
position: 'relative',
|
|
395
|
-
height
|
|
396
|
-
width
|
|
260
|
+
height,
|
|
261
|
+
width,
|
|
397
262
|
overflow: 'auto',
|
|
398
263
|
WebkitOverflowScrolling: 'touch',
|
|
399
264
|
willChange: 'transform',
|
|
400
|
-
direction
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
testID
|
|
405
|
-
|
|
406
|
-
|
|
265
|
+
direction,
|
|
266
|
+
...style
|
|
267
|
+
},
|
|
268
|
+
children: undefined,
|
|
269
|
+
...(testID && {
|
|
270
|
+
testID
|
|
271
|
+
})
|
|
272
|
+
};
|
|
273
|
+
const innerElement = {
|
|
407
274
|
children: items,
|
|
408
275
|
ref: innerRef,
|
|
409
276
|
style: {
|
|
@@ -412,60 +279,258 @@ function createGridComponent(_a) {
|
|
|
412
279
|
width: estimatedTotalWidth || 0
|
|
413
280
|
}
|
|
414
281
|
};
|
|
415
|
-
return (0,
|
|
282
|
+
return /*#__PURE__*/(0, _react.createElement)(outerElementType || outerTagName || 'div', outerRefSetter, /*#__PURE__*/(0, _react.createElement)(innerElementType || innerTagName || 'div', innerElement));
|
|
283
|
+
}
|
|
284
|
+
_outerRefSetter = ref => {
|
|
285
|
+
const {
|
|
286
|
+
outerRef
|
|
287
|
+
} = this.props;
|
|
288
|
+
this._outerRef = ref;
|
|
289
|
+
if (typeof outerRef === 'function') {
|
|
290
|
+
outerRef(ref);
|
|
291
|
+
} else if (outerRef != null && typeof outerRef === 'object' && Object.prototype.hasOwnProperty.call(outerRef, 'current')) {
|
|
292
|
+
outerRef.current = ref;
|
|
293
|
+
}
|
|
416
294
|
};
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
295
|
+
_onScroll = event => {
|
|
296
|
+
const {
|
|
297
|
+
clientHeight,
|
|
298
|
+
clientWidth,
|
|
299
|
+
scrollLeft,
|
|
300
|
+
scrollTop,
|
|
301
|
+
scrollHeight,
|
|
302
|
+
scrollWidth
|
|
303
|
+
} = event.currentTarget;
|
|
304
|
+
this.setState(prevState => {
|
|
305
|
+
if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
|
|
306
|
+
// Scroll position may have been updated by cDM/cDU,
|
|
307
|
+
// In which case we don't need to trigger another render,
|
|
308
|
+
// And we don't want to update state.isScrolling.
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
const {
|
|
312
|
+
direction
|
|
313
|
+
} = this.props;
|
|
314
|
+
|
|
315
|
+
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
|
|
316
|
+
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
|
|
317
|
+
// It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
|
|
318
|
+
// So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
|
|
319
|
+
let calculatedScrollLeft = scrollLeft;
|
|
320
|
+
if (direction === 'rtl') {
|
|
321
|
+
switch ((0, _helper.getRTLOffsetType)()) {
|
|
322
|
+
case 'negative':
|
|
323
|
+
calculatedScrollLeft = -scrollLeft;
|
|
324
|
+
break;
|
|
325
|
+
case 'positive-descending':
|
|
326
|
+
calculatedScrollLeft = scrollWidth - clientWidth - scrollLeft;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
|
|
332
|
+
calculatedScrollLeft = Math.max(0, Math.min(calculatedScrollLeft, scrollWidth - clientWidth));
|
|
333
|
+
const calculatedScrollTop = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
|
|
334
|
+
return {
|
|
335
|
+
isScrolling: true,
|
|
336
|
+
horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
|
|
337
|
+
scrollLeft: calculatedScrollLeft,
|
|
338
|
+
scrollTop: calculatedScrollTop,
|
|
339
|
+
verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward',
|
|
340
|
+
scrollUpdateWasRequested: false
|
|
341
|
+
};
|
|
342
|
+
}, this._resetIsScrollingDebounced);
|
|
343
|
+
};
|
|
344
|
+
_getItemStyle = (rowIndex, columnIndex) => {
|
|
345
|
+
const {
|
|
346
|
+
columnWidth,
|
|
347
|
+
direction,
|
|
348
|
+
rowHeight
|
|
349
|
+
} = this.props;
|
|
350
|
+
const itemStyleCache = this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && columnWidth, shouldResetStyleCacheOnItemSizeChange && direction, shouldResetStyleCacheOnItemSizeChange && rowHeight);
|
|
351
|
+
const key = `${rowIndex}:${columnIndex}`;
|
|
352
|
+
let style;
|
|
353
|
+
if (Object.prototype.hasOwnProperty.call(itemStyleCache, key)) {
|
|
354
|
+
style = itemStyleCache[key];
|
|
355
|
+
} else {
|
|
356
|
+
const offset = getColumnOffset(this.props, columnIndex, this._instanceProps);
|
|
357
|
+
const isRtl = direction === 'rtl';
|
|
358
|
+
itemStyleCache[key] = style = {
|
|
359
|
+
position: 'absolute',
|
|
360
|
+
left: isRtl ? undefined : offset,
|
|
361
|
+
right: isRtl ? offset : undefined,
|
|
362
|
+
top: getRowOffset(this.props, rowIndex, this._instanceProps),
|
|
363
|
+
height: getRowHeight(this.props, rowIndex, this._instanceProps),
|
|
364
|
+
width: getColumnWidth(this.props, columnIndex, this._instanceProps)
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
return style || {};
|
|
368
|
+
};
|
|
369
|
+
_callPropsCallbacks() {
|
|
370
|
+
const {
|
|
371
|
+
columnCount,
|
|
372
|
+
onItemsRendered,
|
|
373
|
+
onScroll,
|
|
374
|
+
rowCount
|
|
375
|
+
} = this.props;
|
|
423
376
|
if (typeof onItemsRendered === 'function') {
|
|
424
377
|
if (columnCount > 0 && rowCount > 0) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
overscanColumnStopIndex = _c[1],
|
|
428
|
-
visibleColumnStartIndex = _c[2],
|
|
429
|
-
visibleColumnStopIndex = _c[3];
|
|
430
|
-
var _d = this._getVerticalRangeToRender(),
|
|
431
|
-
overscanRowStartIndex = _d[0],
|
|
432
|
-
overscanRowStopIndex = _d[1],
|
|
433
|
-
visibleRowStartIndex = _d[2],
|
|
434
|
-
visibleRowStopIndex = _d[3];
|
|
378
|
+
const [overscanColumnStartIndex, overscanColumnStopIndex, visibleColumnStartIndex, visibleColumnStopIndex] = this._getHorizontalRangeToRender();
|
|
379
|
+
const [overscanRowStartIndex, overscanRowStopIndex, visibleRowStartIndex, visibleRowStopIndex] = this._getVerticalRangeToRender();
|
|
435
380
|
this._callOnItemsRendered(overscanColumnStartIndex, overscanColumnStopIndex, overscanRowStartIndex, overscanRowStopIndex, visibleColumnStartIndex, visibleColumnStopIndex, visibleRowStartIndex, visibleRowStopIndex);
|
|
436
381
|
}
|
|
437
382
|
}
|
|
438
383
|
if (typeof onScroll === 'function') {
|
|
439
|
-
|
|
440
|
-
horizontalScrollDirection
|
|
441
|
-
scrollLeft
|
|
442
|
-
scrollTop
|
|
443
|
-
scrollUpdateWasRequested
|
|
444
|
-
verticalScrollDirection
|
|
384
|
+
const {
|
|
385
|
+
horizontalScrollDirection,
|
|
386
|
+
scrollLeft,
|
|
387
|
+
scrollTop,
|
|
388
|
+
scrollUpdateWasRequested,
|
|
389
|
+
verticalScrollDirection
|
|
390
|
+
} = this.state;
|
|
445
391
|
this._callOnScroll(scrollLeft, scrollTop, horizontalScrollDirection, verticalScrollDirection, scrollUpdateWasRequested);
|
|
446
392
|
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
393
|
+
}
|
|
394
|
+
_callOnScroll = (0, _memoizeOne.default)((scrollLeft, scrollTop, horizontalScrollDirection, verticalScrollDirection, scrollUpdateWasRequested) => this.props.onScroll({
|
|
395
|
+
horizontalScrollDirection,
|
|
396
|
+
scrollLeft,
|
|
397
|
+
scrollTop,
|
|
398
|
+
verticalScrollDirection,
|
|
399
|
+
scrollUpdateWasRequested
|
|
400
|
+
}));
|
|
401
|
+
_callOnItemsRendered = (0, _memoizeOne.default)((overscanColumnStartIndex, overscanColumnStopIndex, overscanRowStartIndex, overscanRowStopIndex, visibleColumnStartIndex, visibleColumnStopIndex, visibleRowStartIndex, visibleRowStopIndex) => this.props.onItemsRendered({
|
|
402
|
+
overscanColumnStartIndex,
|
|
403
|
+
overscanColumnStopIndex,
|
|
404
|
+
overscanRowStartIndex,
|
|
405
|
+
overscanRowStopIndex,
|
|
406
|
+
visibleColumnStartIndex,
|
|
407
|
+
visibleColumnStopIndex,
|
|
408
|
+
visibleRowStartIndex,
|
|
409
|
+
visibleRowStopIndex
|
|
410
|
+
}));
|
|
411
|
+
_getVerticalRangeToRender() {
|
|
412
|
+
const {
|
|
413
|
+
columnCount,
|
|
414
|
+
overscanCount,
|
|
415
|
+
overscanRowCount,
|
|
416
|
+
overscanRowsCount,
|
|
417
|
+
rowCount
|
|
418
|
+
} = this.props;
|
|
419
|
+
const {
|
|
420
|
+
isScrolling,
|
|
421
|
+
verticalScrollDirection,
|
|
422
|
+
scrollTop
|
|
423
|
+
} = this.state;
|
|
424
|
+
const overscanCountResolved = overscanRowCount || overscanRowsCount || overscanCount || 1;
|
|
460
425
|
if (columnCount === 0 || rowCount === 0) {
|
|
461
426
|
return [0, 0, 0, 0];
|
|
462
427
|
}
|
|
463
|
-
|
|
464
|
-
|
|
428
|
+
const startIndex = getRowStartIndexForOffset(this.props, scrollTop, this._instanceProps);
|
|
429
|
+
const stopIndex = getRowStopIndexForStartIndex(this.props, startIndex, scrollTop, this._instanceProps);
|
|
430
|
+
|
|
465
431
|
// Overscan by one item in each direction so that tab/focus works.
|
|
466
432
|
// If there isn't at least one extra item, tab loops back around.
|
|
467
|
-
|
|
468
|
-
|
|
433
|
+
const overscanBackward = !isScrolling || verticalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
|
|
434
|
+
const overscanForward = !isScrolling || verticalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
|
|
435
|
+
return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(rowCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
|
|
436
|
+
}
|
|
437
|
+
_getHorizontalRangeToRender() {
|
|
438
|
+
const {
|
|
439
|
+
columnCount,
|
|
440
|
+
overscanColumnCount,
|
|
441
|
+
overscanColumnsCount,
|
|
442
|
+
overscanCount,
|
|
443
|
+
rowCount
|
|
444
|
+
} = this.props;
|
|
445
|
+
const {
|
|
446
|
+
horizontalScrollDirection,
|
|
447
|
+
isScrolling,
|
|
448
|
+
scrollLeft
|
|
449
|
+
} = this.state;
|
|
450
|
+
const overscanCountResolved = overscanColumnCount || overscanColumnsCount || overscanCount || 1;
|
|
451
|
+
if (columnCount === 0 || rowCount === 0) {
|
|
452
|
+
return [0, 0, 0, 0];
|
|
453
|
+
}
|
|
454
|
+
const startIndex = getColumnStartIndexForOffset(this.props, scrollLeft, this._instanceProps);
|
|
455
|
+
const stopIndex = getColumnStopIndexForStartIndex(this.props, startIndex, scrollLeft, this._instanceProps);
|
|
456
|
+
|
|
457
|
+
// Overscan by one item in each direction so that tab/focus works.
|
|
458
|
+
// If there isn't at least one extra item, tab loops back around.
|
|
459
|
+
const overscanBackward = !isScrolling || horizontalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
|
|
460
|
+
const overscanForward = !isScrolling || horizontalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
|
|
461
|
+
return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(columnCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
|
|
462
|
+
}
|
|
463
|
+
_resetIsScrollingDebounced = () => {
|
|
464
|
+
if (this._resetIsScrollingTimeoutId !== null) {
|
|
465
|
+
(0, _timer.cancelTimeout)(this._resetIsScrollingTimeoutId);
|
|
466
|
+
}
|
|
467
|
+
this._resetIsScrollingTimeoutId = (0, _timer.requestTimeout)(this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL);
|
|
468
|
+
};
|
|
469
|
+
_resetIsScrolling = () => {
|
|
470
|
+
this._resetIsScrollingTimeoutId = null;
|
|
471
|
+
this.setState({
|
|
472
|
+
isScrolling: false
|
|
473
|
+
}, () => {
|
|
474
|
+
// Clear style cache after state update has been committed.
|
|
475
|
+
// This way we don't break pure sCU for items that don't use isScrolling param.
|
|
476
|
+
this._getItemStyleCache(-1);
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
_getItemStyleCache = (0, _memoizeOne.default)((_, __, ___) => ({}));
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
const validateSharedProps = ({
|
|
483
|
+
children,
|
|
484
|
+
direction,
|
|
485
|
+
height,
|
|
486
|
+
innerTagName,
|
|
487
|
+
outerTagName,
|
|
488
|
+
overscanColumnsCount,
|
|
489
|
+
overscanCount,
|
|
490
|
+
overscanRowsCount,
|
|
491
|
+
width
|
|
492
|
+
}, {
|
|
493
|
+
instance
|
|
494
|
+
}) => {
|
|
495
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
496
|
+
if (typeof overscanCount === 'number') {
|
|
497
|
+
if (devWarningsOverscanCount && !devWarningsOverscanCount.has(instance)) {
|
|
498
|
+
devWarningsOverscanCount.add(instance);
|
|
499
|
+
console.warn('The overscanCount prop has been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
if (typeof overscanColumnsCount === 'number' || typeof overscanRowsCount === 'number') {
|
|
503
|
+
if (devWarningsOverscanRowsColumnsCount && !devWarningsOverscanRowsColumnsCount.has(instance)) {
|
|
504
|
+
devWarningsOverscanRowsColumnsCount.add(instance);
|
|
505
|
+
console.warn('The overscanColumnsCount and overscanRowsCount props have been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (innerTagName != null || outerTagName != null) {
|
|
509
|
+
if (devWarningsTagName && !devWarningsTagName.has(instance)) {
|
|
510
|
+
devWarningsTagName.add(instance);
|
|
511
|
+
console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
if (children == null) {
|
|
515
|
+
throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + `"${children === null ? 'null' : typeof children}" was specified.`);
|
|
516
|
+
}
|
|
517
|
+
switch (direction) {
|
|
518
|
+
case 'ltr':
|
|
519
|
+
case 'rtl':
|
|
520
|
+
// Valid values
|
|
521
|
+
break;
|
|
522
|
+
default:
|
|
523
|
+
throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + `"${direction}" was specified.`);
|
|
524
|
+
}
|
|
525
|
+
if (typeof width !== 'number') {
|
|
526
|
+
throw Error('An invalid "width" prop has been specified. ' + 'Grids must specify a number for width. ' + `"${width === null ? 'null' : typeof width}" was specified.`);
|
|
527
|
+
}
|
|
528
|
+
if (typeof height !== 'number') {
|
|
529
|
+
throw Error('An invalid "height" prop has been specified. ' + 'Grids must specify a number for height. ' + `"${height === null ? 'null' : typeof height}" was specified.`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
//# sourceMappingURL=Grid.base.js.maption === 'forward' ? Math.max(1, overscanCountResolved) : 1;
|
|
469
534
|
return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(rowCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
|
|
470
535
|
};
|
|
471
536
|
Grid.prototype._getHorizontalRangeToRender = function () {
|