@ringcentral/juno 2.4.1 → 2.5.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/components/Buttons/IconButton/IconButton.d.ts +6 -2
- package/components/Buttons/IconButton/IconButton.js +9 -7
- package/components/Buttons/IconButton/styles/StyledIconButton.js +15 -7
- package/components/Buttons/IconButton/utils/IconButtonUtils.d.ts +1 -1
- package/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
- package/components/Dialer/DialPad/DialPad.d.ts +25 -7
- package/components/Dialer/DialPad/DialPad.js +6 -6
- package/components/Dialer/DialPad/utils/useDialKeyboard.d.ts +8 -9
- package/components/Dialer/DialTextField/DialTextField.d.ts +3 -1
- package/components/Dialer/DialTextField/DialTextField.js +7 -6
- package/components/Downshift/SuggestionList/SuggestionList.d.ts +74 -2
- package/components/Downshift/SuggestionList/SuggestionList.js +4 -1
- package/components/Downshift/styles/DownshiftStyle.d.ts +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledDatePickerHeader.d.ts +1 -1
- package/components/Forms/Picker/DatePicker/styles/StyledYear.d.ts +1 -1
- package/components/Forms/Picker/TimePicker/styles/StyledSelectionItem.d.ts +1 -1
- package/components/Forms/Picker/TimePicker/styles/StyledTimeIconButton.d.ts +1 -1
- package/components/Forms/Picker/styles/PickerBaseIconButton.d.ts +1 -1
- package/components/Forms/TextField/styles/ClearIconButton.d.ts +2 -2
- package/components/Grid/Grid.d.ts +1 -1
- package/components/Pagination/Pagination/Pagination.d.ts +1 -1
- package/components/Stepper/StepButton/StepButton.d.ts +1 -1
- package/components/Stepper/StepLabel/StepLabel.d.ts +1 -1
- package/components/Table/TableCell/styles/TableCellStyle.js +3 -1
- package/components/Table/types.d.ts +1 -1
- package/components/TablePagination/TablePagination.d.ts +1 -1
- package/components/VirtualizedMenu/VirtualizedMenu.js +11 -0
- package/components/VirtualizedMenu/VirtualizedMenuList.js +7 -14
- package/components/Virtuoso/react-virtuoso/AATree.js +15 -15
- package/components/Virtuoso/react-virtuoso/Grid.d.ts +193 -106
- package/components/Virtuoso/react-virtuoso/Grid.js +19 -24
- package/components/Virtuoso/react-virtuoso/List.d.ts +2664 -596
- package/components/Virtuoso/react-virtuoso/List.js +83 -70
- package/components/Virtuoso/react-virtuoso/Table.d.ts +6253 -0
- package/components/Virtuoso/react-virtuoso/Table.js +184 -0
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +153 -37
- package/components/Virtuoso/react-virtuoso/components.d.ts +248 -41
- package/components/Virtuoso/react-virtuoso/components.js +2 -0
- package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +2 -4
- package/components/Virtuoso/react-virtuoso/domIOSystem.js +12 -10
- package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +146 -27
- package/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
- package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +67 -52
- package/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
- package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +17 -3
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +2 -1
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +32 -7
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
- package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -2
- package/components/Virtuoso/react-virtuoso/hooks/useSize.js +26 -28
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
- package/components/Virtuoso/react-virtuoso/index.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/index.js +2 -0
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +165 -35
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +160 -38
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +54 -12
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +26 -10
- package/components/Virtuoso/react-virtuoso/interfaces.d.ts +134 -28
- package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +141 -32
- package/components/Virtuoso/react-virtuoso/listStateSystem.js +1 -2
- package/components/Virtuoso/react-virtuoso/listSystem.d.ts +2123 -407
- package/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
- package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +17 -0
- package/components/Virtuoso/react-virtuoso/loggerSystem.js +37 -0
- package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +8 -1
- package/components/Virtuoso/react-virtuoso/propsReadySystem.js +8 -2
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +641 -0
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +42 -0
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +52 -67
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +26 -5
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +11 -4
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +44 -15
- package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +12 -2
- package/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +17 -5
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +145 -33
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +149 -35
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +183 -42
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +37 -26
- package/components/Virtuoso/react-virtuoso/utils/correctItemSize.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +6 -0
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +7 -4
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
- package/components/Virtuoso/utils/useHighlightScroll.d.ts +4 -0
- package/components/Virtuoso/utils/useHighlightScroll.js +17 -0
- package/es6/components/Buttons/IconButton/IconButton.js +11 -9
- package/es6/components/Buttons/IconButton/styles/StyledIconButton.js +16 -8
- package/es6/components/Buttons/IconButton/utils/IconButtonUtils.js +9 -1
- package/es6/components/Dialer/DialPad/DialPad.js +6 -6
- package/es6/components/Dialer/DialTextField/DialTextField.js +7 -6
- package/es6/components/Downshift/SuggestionList/SuggestionList.js +5 -2
- package/es6/components/Table/TableCell/TableCell.js +2 -2
- package/es6/components/Table/TableCell/styles/TableCellStyle.js +3 -1
- package/es6/components/VirtualizedMenu/VirtualizedMenu.js +13 -2
- package/es6/components/VirtualizedMenu/VirtualizedMenuList.js +9 -16
- package/es6/components/Virtuoso/react-virtuoso/AATree.js +15 -15
- package/es6/components/Virtuoso/react-virtuoso/Grid.js +20 -25
- package/es6/components/Virtuoso/react-virtuoso/List.js +84 -72
- package/es6/components/Virtuoso/react-virtuoso/Table.js +182 -0
- package/es6/components/Virtuoso/react-virtuoso/components.js +2 -0
- package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +13 -10
- package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +28 -15
- package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +17 -15
- package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +31 -6
- package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +40 -26
- package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +27 -29
- package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +32 -12
- package/es6/components/Virtuoso/react-virtuoso/index.js +1 -0
- package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +1 -8
- package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +25 -10
- package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +2 -3
- package/es6/components/Virtuoso/react-virtuoso/listSystem.js +10 -7
- package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +34 -0
- package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +9 -2
- package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +40 -0
- package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +11 -25
- package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +37 -13
- package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +39 -11
- package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +109 -52
- package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +87 -18
- package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +39 -28
- package/es6/components/Virtuoso/react-virtuoso/utils/correctItemSize.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +9 -7
- package/es6/components/Virtuoso/utils/useHighlightScroll.js +16 -0
- package/es6/foundation/hooks/useLongPress/useLongPress.js +7 -7
- package/es6/foundation/index.js +1 -1
- package/es6/foundation/isWebKit154.js +57 -0
- package/es6/foundation/theme/ThemeProvider.js +4 -4
- package/foundation/hooks/useLongPress/useLongPress.d.ts +3 -1
- package/foundation/hooks/useLongPress/useLongPress.js +7 -7
- package/foundation/index.d.ts +1 -1
- package/foundation/index.js +1 -1
- package/foundation/isWebKit154.d.ts +20 -0
- package/foundation/{isSafari154.js → isWebKit154.js} +22 -17
- package/foundation/theme/ThemeProvider.d.ts +1 -1
- package/foundation/theme/ThemeProvider.js +4 -4
- package/package.json +2 -2
- package/es6/foundation/isSafari154.js +0 -52
- package/foundation/isSafari154.d.ts +0 -15
|
@@ -2,7 +2,9 @@ import { __assign, __read, __spread, __values } from "tslib";
|
|
|
2
2
|
/* eslint-disable no-continue */
|
|
3
3
|
import * as u from '@virtuoso.dev/urx';
|
|
4
4
|
import { arrayToRanges, empty, findMaxKeyValue, insert, newTree, rangesWithin, remove, walk, } from './AATree';
|
|
5
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
5
6
|
import * as arrayBinarySearch from './utils/binaryArraySearch';
|
|
7
|
+
import { correctItemSize } from './utils/correctItemSize';
|
|
6
8
|
function rangeIncludes(refRange) {
|
|
7
9
|
var size = refRange.size, startIndex = refRange.startIndex, endIndex = refRange.endIndex;
|
|
8
10
|
return function (range) {
|
|
@@ -103,80 +105,92 @@ export function rangesWithinOffsets(tree, startOffset, endOffset, minStartIndex)
|
|
|
103
105
|
}
|
|
104
106
|
return arrayToRanges(arrayBinarySearch.findRange(tree, startOffset, endOffset, offsetComparator), offsetPointParser);
|
|
105
107
|
}
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
var sizeTree = state.sizeTree;
|
|
110
|
-
var offsetTree = state.offsetTree;
|
|
111
|
-
var newSizeTree = sizeTree;
|
|
112
|
-
var syncStart = 0;
|
|
113
|
-
// We receive probe item results from a group probe,
|
|
114
|
-
// which should always pass an item and a group
|
|
115
|
-
// the results contain two ranges, which we consider to mean that groups and items have different size
|
|
116
|
-
if (groupIndices.length > 0 && empty(sizeTree) && ranges.length === 2) {
|
|
117
|
-
var groupSize_1 = ranges[0].size;
|
|
118
|
-
var itemSize_1 = ranges[1].size;
|
|
119
|
-
newSizeTree = groupIndices.reduce(function (tree, groupIndex) {
|
|
120
|
-
return insert(insert(tree, groupIndex, groupSize_1), groupIndex + 1, itemSize_1);
|
|
121
|
-
}, newSizeTree);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
_b = __read(insertRanges(newSizeTree, ranges), 2), newSizeTree = _b[0], syncStart = _b[1];
|
|
125
|
-
}
|
|
126
|
-
if (newSizeTree === sizeTree) {
|
|
127
|
-
return state;
|
|
128
|
-
}
|
|
108
|
+
function createOffsetTree(prevOffsetTree, syncStart, sizeTree) {
|
|
109
|
+
var e_3, _a;
|
|
110
|
+
var offsetTree = prevOffsetTree;
|
|
129
111
|
var prevIndex = 0;
|
|
130
112
|
var prevSize = 0;
|
|
131
|
-
var
|
|
132
|
-
var
|
|
113
|
+
var prevOffset = 0;
|
|
114
|
+
var startIndex = 0;
|
|
133
115
|
if (syncStart !== 0) {
|
|
134
|
-
|
|
135
|
-
var offsetInfo = offsetTree[
|
|
136
|
-
|
|
137
|
-
var kv = findMaxKeyValue(
|
|
116
|
+
startIndex = arrayBinarySearch.findIndexOfClosestSmallerOrEqual(offsetTree, syncStart - 1, indexComparator);
|
|
117
|
+
var offsetInfo = offsetTree[startIndex];
|
|
118
|
+
prevOffset = offsetInfo.offset;
|
|
119
|
+
var kv = findMaxKeyValue(sizeTree, syncStart - 1);
|
|
138
120
|
prevIndex = kv[0];
|
|
139
121
|
prevSize = kv[1];
|
|
140
122
|
if (offsetTree.length &&
|
|
141
|
-
offsetTree[
|
|
142
|
-
|
|
143
|
-
startAIndex -= 1;
|
|
123
|
+
offsetTree[startIndex].size === findMaxKeyValue(sizeTree, syncStart)[1]) {
|
|
124
|
+
startIndex -= 1;
|
|
144
125
|
}
|
|
145
|
-
offsetTree = offsetTree.slice(0,
|
|
126
|
+
offsetTree = offsetTree.slice(0, startIndex + 1);
|
|
146
127
|
}
|
|
147
128
|
else {
|
|
148
129
|
offsetTree = [];
|
|
149
130
|
}
|
|
150
131
|
try {
|
|
151
|
-
for (var
|
|
152
|
-
var
|
|
153
|
-
var aOffset = (
|
|
132
|
+
for (var _b = __values(rangesWithin(sizeTree, syncStart, Infinity)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
133
|
+
var _d = _c.value, startIndex_1 = _d.start, value = _d.value;
|
|
134
|
+
var aOffset = (startIndex_1 - prevIndex) * prevSize + prevOffset;
|
|
154
135
|
offsetTree.push({
|
|
155
136
|
offset: aOffset,
|
|
156
137
|
size: value,
|
|
157
|
-
index:
|
|
138
|
+
index: startIndex_1,
|
|
158
139
|
});
|
|
159
|
-
prevIndex =
|
|
160
|
-
|
|
140
|
+
prevIndex = startIndex_1;
|
|
141
|
+
prevOffset = aOffset;
|
|
161
142
|
prevSize = value;
|
|
162
143
|
}
|
|
163
144
|
}
|
|
164
145
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
165
146
|
finally {
|
|
166
147
|
try {
|
|
167
|
-
if (
|
|
148
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
168
149
|
}
|
|
169
150
|
finally { if (e_3) throw e_3.error; }
|
|
170
151
|
}
|
|
171
152
|
return {
|
|
172
|
-
sizeTree: newSizeTree,
|
|
173
153
|
offsetTree: offsetTree,
|
|
174
|
-
groupOffsetTree: groupIndices.reduce(function (tree, index) {
|
|
175
|
-
return insert(tree, index, offsetOf(index, offsetTree));
|
|
176
|
-
}, newTree()),
|
|
177
154
|
lastIndex: prevIndex,
|
|
178
|
-
lastOffset:
|
|
155
|
+
lastOffset: prevOffset,
|
|
179
156
|
lastSize: prevSize,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export function sizeStateReducer(state, _a) {
|
|
160
|
+
var _b;
|
|
161
|
+
var _c = __read(_a, 3), ranges = _c[0], groupIndices = _c[1], log = _c[2];
|
|
162
|
+
if (ranges.length > 0) {
|
|
163
|
+
log('received item sizes', ranges, LogLevel.DEBUG);
|
|
164
|
+
}
|
|
165
|
+
var sizeTree = state.sizeTree;
|
|
166
|
+
var newSizeTree = sizeTree;
|
|
167
|
+
var syncStart = 0;
|
|
168
|
+
// We receive probe item results from a group probe,
|
|
169
|
+
// which should always pass an item and a group
|
|
170
|
+
// the results contain two ranges, which we consider to mean that groups and items have different size
|
|
171
|
+
if (groupIndices.length > 0 && empty(sizeTree) && ranges.length === 2) {
|
|
172
|
+
var groupSize_1 = ranges[0].size;
|
|
173
|
+
var itemSize_1 = ranges[1].size;
|
|
174
|
+
newSizeTree = groupIndices.reduce(function (tree, groupIndex) {
|
|
175
|
+
return insert(insert(tree, groupIndex, groupSize_1), groupIndex + 1, itemSize_1);
|
|
176
|
+
}, newSizeTree);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
_b = __read(insertRanges(newSizeTree, ranges), 2), newSizeTree = _b[0], syncStart = _b[1];
|
|
180
|
+
}
|
|
181
|
+
if (newSizeTree === sizeTree) {
|
|
182
|
+
return state;
|
|
183
|
+
}
|
|
184
|
+
var _d = createOffsetTree(state.offsetTree, syncStart, newSizeTree), newOffsetTree = _d.offsetTree, lastIndex = _d.lastIndex, lastSize = _d.lastSize, lastOffset = _d.lastOffset;
|
|
185
|
+
return {
|
|
186
|
+
sizeTree: newSizeTree,
|
|
187
|
+
offsetTree: newOffsetTree,
|
|
188
|
+
lastIndex: lastIndex,
|
|
189
|
+
lastOffset: lastOffset,
|
|
190
|
+
lastSize: lastSize,
|
|
191
|
+
groupOffsetTree: groupIndices.reduce(function (tree, index) {
|
|
192
|
+
return insert(tree, index, offsetOf(index, newOffsetTree));
|
|
193
|
+
}, newTree()),
|
|
180
194
|
groupIndices: groupIndices,
|
|
181
195
|
};
|
|
182
196
|
}
|
|
@@ -201,18 +215,27 @@ export function originalIndexFromItemIndex(itemIndex, sizes) {
|
|
|
201
215
|
export function hasGroups(sizes) {
|
|
202
216
|
return !empty(sizes.groupOffsetTree);
|
|
203
217
|
}
|
|
204
|
-
|
|
218
|
+
var SIZE_MAP = {
|
|
219
|
+
offsetHeight: 'height',
|
|
220
|
+
offsetWidth: 'width',
|
|
221
|
+
};
|
|
222
|
+
export var sizeSystem = u.system(function (_a) {
|
|
223
|
+
var _b = __read(_a, 1), log = _b[0].log;
|
|
205
224
|
var sizeRanges = u.stream();
|
|
206
225
|
var totalCount = u.stream();
|
|
226
|
+
var statefulTotalCount = u.statefulStreamFromEmitter(totalCount, 0);
|
|
207
227
|
var unshiftWith = u.stream();
|
|
228
|
+
var shiftWith = u.stream();
|
|
208
229
|
var firstItemIndex = u.statefulStream(0);
|
|
209
230
|
var groupIndices = u.statefulStream([]);
|
|
210
231
|
var fixedItemSize = u.statefulStream(undefined);
|
|
211
232
|
var defaultItemSize = u.statefulStream(undefined);
|
|
212
|
-
var itemSize = u.statefulStream(function (el, field) {
|
|
233
|
+
var itemSize = u.statefulStream(function (el, field) {
|
|
234
|
+
return correctItemSize(el, SIZE_MAP[field]);
|
|
235
|
+
});
|
|
213
236
|
var data = u.statefulStream(undefined);
|
|
214
237
|
var initial = initialSizeState();
|
|
215
|
-
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
238
|
+
var sizes = u.statefulStreamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(groupIndices, log), u.scan(sizeStateReducer, initial), u.distinctUntilChanged()), initial);
|
|
216
239
|
u.connect(u.pipe(groupIndices, u.filter(function (indexes) { return indexes.length > 0; }), u.withLatestFrom(sizes), u.map(function (_a) {
|
|
217
240
|
var _b = __read(_a, 2), groupIndices = _b[0], sizes = _b[1];
|
|
218
241
|
var groupOffsetTree = groupIndices.reduce(function (tree, index, idx) {
|
|
@@ -238,7 +261,9 @@ export var sizeSystem = u.system(function () {
|
|
|
238
261
|
})), sizeRanges);
|
|
239
262
|
u.connect(fixedItemSize, defaultItemSize);
|
|
240
263
|
var trackItemSizes = u.statefulStreamFromEmitter(u.pipe(fixedItemSize, u.map(function (size) { return size === undefined; })), true);
|
|
241
|
-
u.connect(u.pipe(defaultItemSize, u.filter(function (value) {
|
|
264
|
+
u.connect(u.pipe(defaultItemSize, u.filter(function (value) {
|
|
265
|
+
return value !== undefined && empty(u.getValue(sizes).sizeTree);
|
|
266
|
+
}), u.map(function (size) { return [{ startIndex: 0, endIndex: 0, size: size }]; })), sizeRanges);
|
|
242
267
|
var listRefresh = u.streamFromEmitter(u.pipe(sizeRanges, u.withLatestFrom(sizes), u.scan(function (_a, _b) {
|
|
243
268
|
var oldSizes = _a.sizes;
|
|
244
269
|
var _c = __read(_b, 2), newSizes = _c[1];
|
|
@@ -247,9 +272,22 @@ export var sizeSystem = u.system(function () {
|
|
|
247
272
|
sizes: newSizes,
|
|
248
273
|
};
|
|
249
274
|
}, { changed: false, sizes: initial }), u.map(function (value) { return value.changed; })));
|
|
250
|
-
u.
|
|
275
|
+
u.subscribe(u.pipe(firstItemIndex, u.scan(function (prev, next) {
|
|
251
276
|
return { diff: prev.prev - next, prev: next };
|
|
252
|
-
}, { diff: 0, prev: 0 }), u.map(function (val) { return val.diff; }),
|
|
277
|
+
}, { diff: 0, prev: 0 }), u.map(function (val) { return val.diff; })), function (offset) {
|
|
278
|
+
if (offset > 0) {
|
|
279
|
+
u.publish(unshiftWith, offset);
|
|
280
|
+
}
|
|
281
|
+
else if (offset < 0) {
|
|
282
|
+
u.publish(shiftWith, offset);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
u.subscribe(u.pipe(firstItemIndex, u.withLatestFrom(log)), function (_a) {
|
|
286
|
+
var _b = __read(_a, 2), index = _b[0], log = _b[1];
|
|
287
|
+
if (index < 0) {
|
|
288
|
+
log("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value", { firstItemIndex: firstItemIndex }, LogLevel.ERROR);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
253
291
|
// Capture the current list top item before the sizes get refreshed
|
|
254
292
|
var beforeUnshiftWith = u.streamFromEmitter(unshiftWith);
|
|
255
293
|
u.connect(u.pipe(unshiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
@@ -276,6 +314,22 @@ export var sizeSystem = u.system(function () {
|
|
|
276
314
|
prevSize: sizes.lastSize,
|
|
277
315
|
}).ranges;
|
|
278
316
|
})), sizeRanges);
|
|
317
|
+
var shiftWithOffset = u.streamFromEmitter(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
318
|
+
var _b = __read(_a, 2), shiftWith = _b[0], offsetTree = _b[1].offsetTree;
|
|
319
|
+
var newFirstItemIndex = -shiftWith;
|
|
320
|
+
return offsetOf(newFirstItemIndex, offsetTree);
|
|
321
|
+
})));
|
|
322
|
+
u.connect(u.pipe(shiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
323
|
+
var _b = __read(_a, 2), shiftWith = _b[0], sizes = _b[1];
|
|
324
|
+
if (sizes.groupIndices.length > 0) {
|
|
325
|
+
throw new Error('Virtuoso: shifting items does not work with groups');
|
|
326
|
+
}
|
|
327
|
+
var newSizeTree = walk(sizes.sizeTree).reduce(function (acc, _a) {
|
|
328
|
+
var k = _a.k, v = _a.v;
|
|
329
|
+
return insert(acc, Math.max(0, k + shiftWith), v);
|
|
330
|
+
}, newTree());
|
|
331
|
+
return __assign(__assign(__assign({}, sizes), { sizeTree: newSizeTree }), createOffsetTree(sizes.offsetTree, 0, newSizeTree));
|
|
332
|
+
})), sizes);
|
|
279
333
|
return {
|
|
280
334
|
// input
|
|
281
335
|
data: data,
|
|
@@ -285,12 +339,15 @@ export var sizeSystem = u.system(function () {
|
|
|
285
339
|
defaultItemSize: defaultItemSize,
|
|
286
340
|
fixedItemSize: fixedItemSize,
|
|
287
341
|
unshiftWith: unshiftWith,
|
|
342
|
+
shiftWith: shiftWith,
|
|
343
|
+
shiftWithOffset: shiftWithOffset,
|
|
288
344
|
beforeUnshiftWith: beforeUnshiftWith,
|
|
289
345
|
firstItemIndex: firstItemIndex,
|
|
290
346
|
// output
|
|
291
347
|
sizes: sizes,
|
|
292
348
|
listRefresh: listRefresh,
|
|
349
|
+
statefulTotalCount: statefulTotalCount,
|
|
293
350
|
trackItemSizes: trackItemSizes,
|
|
294
351
|
itemSize: itemSize,
|
|
295
352
|
};
|
|
296
|
-
},
|
|
353
|
+
}, u.tup(loggerSystem), { singleton: true });
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
3
|
import * as u from '@virtuoso.dev/urx';
|
|
3
4
|
import { domIOSystem } from './domIOSystem';
|
|
5
|
+
export var UP = 'up';
|
|
6
|
+
export var DOWN = 'down';
|
|
7
|
+
export var NONE = 'none';
|
|
4
8
|
var INITIAL_BOTTOM_STATE = {
|
|
5
9
|
atBottom: false,
|
|
6
10
|
notAtBottomBecause: 'NOT_SHOWING_LAST_ITEM',
|
|
@@ -8,42 +12,54 @@ var INITIAL_BOTTOM_STATE = {
|
|
|
8
12
|
offsetBottom: 0,
|
|
9
13
|
scrollTop: 0,
|
|
10
14
|
viewportHeight: 0,
|
|
11
|
-
|
|
15
|
+
scrollHeight: 0,
|
|
12
16
|
},
|
|
13
17
|
};
|
|
14
18
|
export var stateFlagsSystem = u.system(function (_a) {
|
|
15
|
-
var _b = __read(_a, 1), _c = _b[0], scrollTop = _c.scrollTop, viewportHeight = _c.viewportHeight;
|
|
19
|
+
var _b = __read(_a, 1), _c = _b[0], scrollContainerState = _c.scrollContainerState, scrollTop = _c.scrollTop, viewportHeight = _c.viewportHeight, headerHeight = _c.headerHeight, footerHeight = _c.footerHeight, scrollBy = _c.scrollBy;
|
|
16
20
|
var isAtBottom = u.statefulStream(false);
|
|
17
21
|
var isAtTop = u.statefulStream(true);
|
|
18
22
|
var atBottomStateChange = u.stream();
|
|
19
23
|
var atTopStateChange = u.stream();
|
|
20
|
-
var
|
|
24
|
+
var atBottomThreshold = u.statefulStream(4);
|
|
21
25
|
// skip 1 to avoid an initial on/off flick
|
|
22
26
|
var isScrolling = u.streamFromEmitter(u.pipe(u.merge(u.pipe(u.duc(scrollTop), u.skip(1), u.mapTo(true)), u.pipe(u.duc(scrollTop), u.skip(1), u.mapTo(false), u.debounceTime(100))), u.distinctUntilChanged()));
|
|
27
|
+
var isScrollingBy = u.statefulStreamFromEmitter(u.pipe(u.merge(u.pipe(scrollBy, u.mapTo(true)), u.pipe(scrollBy, u.mapTo(false), u.debounceTime(200))), u.distinctUntilChanged()), false);
|
|
28
|
+
// u.subscribe(isScrollingBy, (isScrollingBy) => console.log({ isScrollingBy }))
|
|
23
29
|
u.connect(u.pipe(u.duc(scrollTop), u.map(function (top) { return top === 0; }), u.distinctUntilChanged()), isAtTop);
|
|
24
30
|
u.connect(isAtTop, atTopStateChange);
|
|
25
|
-
var atBottomState = u.streamFromEmitter(u.pipe(u.combineLatest(
|
|
26
|
-
var _b = __read(_a,
|
|
27
|
-
var isAtBottom =
|
|
31
|
+
var atBottomState = u.streamFromEmitter(u.pipe(u.combineLatest(scrollContainerState, u.duc(viewportHeight), u.duc(headerHeight), u.duc(footerHeight), u.duc(atBottomThreshold)), u.scan(function (current, _a) {
|
|
32
|
+
var _b = __read(_a, 5), _c = __read(_b[0], 2), scrollTop = _c[0], scrollHeight = _c[1], viewportHeight = _b[1], _headerHeight = _b[2], _footerHeight = _b[3], atBottomThreshold = _b[4];
|
|
33
|
+
var isAtBottom = scrollTop + viewportHeight - scrollHeight > -atBottomThreshold;
|
|
28
34
|
var state = {
|
|
29
35
|
viewportHeight: viewportHeight,
|
|
30
36
|
scrollTop: scrollTop,
|
|
31
|
-
|
|
32
|
-
totalHeight: bottom + offsetBottom,
|
|
37
|
+
scrollHeight: scrollHeight,
|
|
33
38
|
};
|
|
34
39
|
if (isAtBottom) {
|
|
40
|
+
var atBottomBecause = void 0;
|
|
41
|
+
var scrollTopDelta = void 0;
|
|
42
|
+
if (scrollTop > current.state.scrollTop) {
|
|
43
|
+
atBottomBecause = 'SCROLLED_DOWN';
|
|
44
|
+
scrollTopDelta = current.state.scrollTop - scrollTop;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
atBottomBecause = 'SIZE_DECREASED';
|
|
48
|
+
scrollTopDelta =
|
|
49
|
+
current.state.scrollTop - scrollTop ||
|
|
50
|
+
current.scrollTopDelta;
|
|
51
|
+
}
|
|
35
52
|
return {
|
|
36
53
|
atBottom: true,
|
|
37
54
|
state: state,
|
|
55
|
+
atBottomBecause: atBottomBecause,
|
|
56
|
+
scrollTopDelta: scrollTopDelta,
|
|
38
57
|
};
|
|
39
58
|
}
|
|
40
59
|
var notAtBottomBecause;
|
|
41
|
-
if (state.
|
|
60
|
+
if (state.scrollHeight > current.state.scrollHeight) {
|
|
42
61
|
notAtBottomBecause = 'SIZE_INCREASED';
|
|
43
62
|
}
|
|
44
|
-
else if (offsetBottom !== 0) {
|
|
45
|
-
notAtBottomBecause = 'NOT_SHOWING_LAST_ITEM';
|
|
46
|
-
}
|
|
47
63
|
else if (viewportHeight < current.state.viewportHeight) {
|
|
48
64
|
notAtBottomBecause = 'VIEWPORT_HEIGHT_DECREASING';
|
|
49
65
|
}
|
|
@@ -59,14 +75,64 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
59
75
|
state: state,
|
|
60
76
|
};
|
|
61
77
|
}, INITIAL_BOTTOM_STATE), u.distinctUntilChanged(function (prev, next) {
|
|
62
|
-
// prev && console.log(prev.atBottom, next.atBottom)
|
|
63
78
|
return prev && prev.atBottom === next.atBottom;
|
|
64
79
|
})));
|
|
80
|
+
var lastJumpDueToItemResize = u.statefulStreamFromEmitter(u.pipe(scrollContainerState, u.scan(function (current, _a) {
|
|
81
|
+
var _b = __read(_a, 2), scrollTop = _b[0], scrollHeight = _b[1];
|
|
82
|
+
if (current.scrollHeight !== scrollHeight) {
|
|
83
|
+
if (current.scrollTop !== scrollTop) {
|
|
84
|
+
return {
|
|
85
|
+
scrollHeight: scrollHeight,
|
|
86
|
+
scrollTop: scrollTop,
|
|
87
|
+
jump: current.scrollTop - scrollTop,
|
|
88
|
+
changed: true,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
scrollHeight: scrollHeight,
|
|
93
|
+
scrollTop: scrollTop,
|
|
94
|
+
jump: 0,
|
|
95
|
+
changed: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
scrollTop: scrollTop,
|
|
100
|
+
scrollHeight: scrollHeight,
|
|
101
|
+
jump: 0,
|
|
102
|
+
changed: false,
|
|
103
|
+
};
|
|
104
|
+
}, { scrollHeight: 0, jump: 0, scrollTop: 0, changed: false }), u.filter(function (value) { return value.changed; }), u.map(function (value) { return value.jump; })), 0);
|
|
65
105
|
u.connect(u.pipe(atBottomState, u.map(function (state) { return state.atBottom; })), isAtBottom);
|
|
66
|
-
u.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
106
|
+
u.connect(u.pipe(isAtBottom, u.throttleTime(50)), atBottomStateChange);
|
|
107
|
+
var scrollDirection = u.statefulStream(DOWN);
|
|
108
|
+
u.connect(u.pipe(scrollContainerState, u.map(function (_a) {
|
|
109
|
+
var _b = __read(_a, 1), scrollTop = _b[0];
|
|
110
|
+
return scrollTop;
|
|
111
|
+
}), u.distinctUntilChanged(), u.scan(function (acc, scrollTop) {
|
|
112
|
+
// if things change while compensating for items, ignore,
|
|
113
|
+
// but store the new scrollTop
|
|
114
|
+
if (u.getValue(isScrollingBy)) {
|
|
115
|
+
return { direction: acc.direction, prevScrollTop: scrollTop };
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
direction: scrollTop < acc.prevScrollTop ? UP : DOWN,
|
|
119
|
+
prevScrollTop: scrollTop,
|
|
120
|
+
};
|
|
121
|
+
}, { direction: DOWN, prevScrollTop: 0 }), u.map(function (value) { return value.direction; })), scrollDirection);
|
|
122
|
+
u.connect(u.pipe(scrollContainerState, u.throttleTime(50), u.mapTo(NONE)), scrollDirection);
|
|
123
|
+
var scrollVelocity = u.statefulStream(0);
|
|
124
|
+
u.connect(u.pipe(isScrolling, u.filter(function (value) { return !value; }), u.mapTo(0)), scrollVelocity);
|
|
125
|
+
u.connect(u.pipe(scrollTop, u.throttleTime(100), u.withLatestFrom(isScrolling), u.filter(function (_a) {
|
|
126
|
+
var _b = __read(_a, 2), _ = _b[0], isScrolling = _b[1];
|
|
127
|
+
return !!isScrolling;
|
|
128
|
+
}), u.scan(function (_a, _b) {
|
|
129
|
+
var _c = __read(_a, 2), _ = _c[0], prev = _c[1];
|
|
130
|
+
var _d = __read(_b, 1), next = _d[0];
|
|
131
|
+
return [prev, next];
|
|
132
|
+
}, [0, 0]), u.map(function (_a) {
|
|
133
|
+
var _b = __read(_a, 2), prev = _b[0], next = _b[1];
|
|
134
|
+
return next - prev;
|
|
135
|
+
})), scrollVelocity);
|
|
70
136
|
return {
|
|
71
137
|
isScrolling: isScrolling,
|
|
72
138
|
isAtTop: isAtTop,
|
|
@@ -74,6 +140,9 @@ export var stateFlagsSystem = u.system(function (_a) {
|
|
|
74
140
|
atBottomState: atBottomState,
|
|
75
141
|
atTopStateChange: atTopStateChange,
|
|
76
142
|
atBottomStateChange: atBottomStateChange,
|
|
77
|
-
|
|
143
|
+
scrollDirection: scrollDirection,
|
|
144
|
+
atBottomThreshold: atBottomThreshold,
|
|
145
|
+
scrollVelocity: scrollVelocity,
|
|
146
|
+
lastJumpDueToItemResize: lastJumpDueToItemResize,
|
|
78
147
|
};
|
|
79
148
|
}, u.tup(domIOSystem));
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
2
|
/* eslint-disable no-continue */
|
|
3
3
|
import * as u from '@virtuoso.dev/urx';
|
|
4
|
-
import { domIOSystem
|
|
4
|
+
import { domIOSystem } from './domIOSystem';
|
|
5
5
|
import { listStateSystem } from './listStateSystem';
|
|
6
|
+
import { loggerSystem, LogLevel } from './loggerSystem';
|
|
6
7
|
import { sizeSystem } from './sizeSystem';
|
|
7
|
-
import { stateFlagsSystem } from './stateFlagsSystem';
|
|
8
|
+
import { stateFlagsSystem, UP } from './stateFlagsSystem';
|
|
8
9
|
/**
|
|
9
10
|
* Fixes upward scrolling by calculating and compensation from changed item heights, using scrollBy.
|
|
10
11
|
*/
|
|
11
12
|
export var upwardScrollFixSystem = u.system(function (_a) {
|
|
12
|
-
var _b = __read(_a,
|
|
13
|
-
var deviationOffset = u.streamFromEmitter(u.pipe(listState, u.withLatestFrom(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _c = __read(_a, 2), prevItems = _c[1];
|
|
21
|
-
var items = _b.items;
|
|
13
|
+
var _b = __read(_a, 5), _c = _b[0], scrollBy = _c.scrollBy, scrollTop = _c.scrollTop, deviation = _c.deviation, scrollingInProgress = _c.scrollingInProgress, _d = _b[1], isScrolling = _d.isScrolling, isAtBottom = _d.isAtBottom, atBottomState = _d.atBottomState, scrollDirection = _d.scrollDirection, lastJumpDueToItemResize = _d.lastJumpDueToItemResize, listState = _b[2].listState, _e = _b[3], beforeUnshiftWith = _e.beforeUnshiftWith, shiftWithOffset = _e.shiftWithOffset, sizes = _e.sizes, log = _b[4].log;
|
|
14
|
+
var deviationOffset = u.streamFromEmitter(u.pipe(listState, u.withLatestFrom(lastJumpDueToItemResize), u.scan(function (_a,
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
_b) {
|
|
17
|
+
var _c = __read(_a, 3), prevItems = _c[1], prevTotalCount = _c[2];
|
|
18
|
+
var
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
_d = __read(_b, 2), _e = _d[0], items = _e.items, totalCount = _e.totalCount, lastJumpDueToItemResize = _d[1];
|
|
22
21
|
var newDev = 0;
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
newDev = items[0].size - prevItems[0].size;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
22
|
+
if (prevTotalCount === totalCount) {
|
|
23
|
+
if (prevItems.length > 0 && items.length > 0) {
|
|
24
|
+
var firstItemIndex = items[0].originalIndex;
|
|
25
|
+
var prevFirstItemIndex = prevItems[0].originalIndex;
|
|
26
|
+
var atStart = firstItemIndex === 0 && prevFirstItemIndex === 0;
|
|
27
|
+
var onlyItem = items.length === 1;
|
|
28
|
+
if (!atStart) {
|
|
33
29
|
var _loop_1 = function (index) {
|
|
34
30
|
var item = items[index];
|
|
35
31
|
var prevItem = prevItems.find(function (pItem) { return pItem.originalIndex === item.originalIndex; });
|
|
36
32
|
if (!prevItem) {
|
|
37
33
|
return "continue";
|
|
38
34
|
}
|
|
39
|
-
if (item.offset !== prevItem.offset) {
|
|
40
|
-
newDev =
|
|
35
|
+
if (item.offset !== prevItem.offset || onlyItem) {
|
|
36
|
+
newDev =
|
|
37
|
+
item.offset -
|
|
38
|
+
prevItem.offset +
|
|
39
|
+
item.size -
|
|
40
|
+
prevItem.size;
|
|
41
41
|
return "break";
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -48,13 +48,21 @@ export var upwardScrollFixSystem = u.system(function (_a) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
if (newDev !== 0) {
|
|
52
|
+
newDev += lastJumpDueToItemResize;
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
|
-
return [newDev, items];
|
|
53
|
-
}, [0, []]), u.filter(function (_a) {
|
|
55
|
+
return [newDev, items, totalCount];
|
|
56
|
+
}, [0, [], 0]), u.filter(function (_a) {
|
|
54
57
|
var _b = __read(_a, 1), amount = _b[0];
|
|
55
58
|
return amount !== 0;
|
|
59
|
+
}), u.withLatestFrom(scrollTop, scrollDirection, scrollingInProgress, log, isAtBottom, atBottomState), u.filter(function (_a) {
|
|
60
|
+
var _b = __read(_a, 4), scrollTop = _b[1], scrollDirection = _b[2], scrollingInProgress = _b[3];
|
|
61
|
+
// console.log({ amount, scrollTop, scrollDirection, scrollingInProgress, isAtBottom, atBottomState })
|
|
62
|
+
return (!scrollingInProgress && scrollTop !== 0 && scrollDirection === UP); // && (isAtBottom ? amount > 0 : true)
|
|
56
63
|
}), u.map(function (_a) {
|
|
57
|
-
var _b = __read(_a, 1), amount =
|
|
64
|
+
var _b = __read(_a, 5), _c = __read(_b[0], 1), amount = _c[0], log = _b[4];
|
|
65
|
+
log('Upward scrolling compensation', { amount: amount }, LogLevel.DEBUG);
|
|
58
66
|
return amount;
|
|
59
67
|
})));
|
|
60
68
|
u.connect(u.pipe(deviationOffset, u.withLatestFrom(deviation), u.map(function (_a) {
|
|
@@ -79,9 +87,12 @@ export var upwardScrollFixSystem = u.system(function (_a) {
|
|
|
79
87
|
u.publish(scrollBy, { top: -offset, behavior: 'auto' });
|
|
80
88
|
}
|
|
81
89
|
});
|
|
90
|
+
u.connect(u.pipe(shiftWithOffset, u.map(function (offset) {
|
|
91
|
+
return { top: -offset };
|
|
92
|
+
})), scrollBy);
|
|
82
93
|
u.connect(u.pipe(beforeUnshiftWith, u.withLatestFrom(sizes), u.map(function (_a) {
|
|
83
94
|
var _b = __read(_a, 2), offset = _b[0], lastSize = _b[1].lastSize;
|
|
84
95
|
return offset * lastSize;
|
|
85
96
|
})), deviationOffset);
|
|
86
97
|
return { deviation: deviation };
|
|
87
|
-
}, u.tup(domIOSystem, stateFlagsSystem, listStateSystem, sizeSystem));
|
|
98
|
+
}, u.tup(domIOSystem, stateFlagsSystem, listStateSystem, sizeSystem, loggerSystem));
|
|
@@ -2,15 +2,16 @@ import { __assign, __read } from "tslib";
|
|
|
2
2
|
import * as u from '@virtuoso.dev/urx';
|
|
3
3
|
import { domIOSystem } from './domIOSystem';
|
|
4
4
|
export var windowScrollerSystem = u.system(function (_a) {
|
|
5
|
-
var _b = __read(_a, 1), _c = _b[0],
|
|
5
|
+
var _b = __read(_a, 1), _c = _b[0], scrollTo = _c.scrollTo, scrollContainerState = _c.scrollContainerState;
|
|
6
|
+
var windowScrollContainerState = u.stream();
|
|
6
7
|
var windowViewportRect = u.stream();
|
|
7
|
-
var windowScrollTop = u.stream();
|
|
8
8
|
var windowScrollTo = u.stream();
|
|
9
9
|
var useWindowScroll = u.statefulStream(false);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
var customScrollParent = u.statefulStream(undefined);
|
|
11
|
+
u.connect(u.pipe(u.combineLatest(windowScrollContainerState, windowViewportRect), u.map(function (_a) {
|
|
12
|
+
var _b = __read(_a, 2), _c = __read(_b[0], 2), windowScrollTop = _c[0], scrollHeight = _c[1], offsetTop = _b[1].offsetTop;
|
|
13
|
+
return [Math.max(0, windowScrollTop - offsetTop), scrollHeight];
|
|
14
|
+
})), scrollContainerState);
|
|
14
15
|
u.connect(u.pipe(scrollTo, u.withLatestFrom(windowViewportRect), u.map(function (_a) {
|
|
15
16
|
var _b = __read(_a, 2), scrollTo = _b[0], offsetTop = _b[1].offsetTop;
|
|
16
17
|
return __assign(__assign({}, scrollTo), { top: scrollTo.top + offsetTop });
|
|
@@ -18,8 +19,9 @@ export var windowScrollerSystem = u.system(function (_a) {
|
|
|
18
19
|
return {
|
|
19
20
|
// config
|
|
20
21
|
useWindowScroll: useWindowScroll,
|
|
22
|
+
customScrollParent: customScrollParent,
|
|
21
23
|
// input
|
|
22
|
-
|
|
24
|
+
windowScrollContainerState: windowScrollContainerState,
|
|
23
25
|
windowViewportRect: windowViewportRect,
|
|
24
26
|
// signals
|
|
25
27
|
windowScrollTo: windowScrollTo,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
+
import { fixWebKitTransitionStyle } from '../../../foundation';
|
|
2
3
|
/**
|
|
3
4
|
* scroll into current highlight index
|
|
4
5
|
*/
|
|
@@ -98,3 +99,18 @@ export function useHighlightScroll(_a) {
|
|
|
98
99
|
itemsRendered: function (e) { return (renderedItemsRef.current = e); },
|
|
99
100
|
};
|
|
100
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* modify virtuoso style to fix safari scroll bug
|
|
104
|
+
*/
|
|
105
|
+
export function modifyVlScrollerStyle(scrollElm, position) {
|
|
106
|
+
if (position === void 0) { position = 'absolute'; }
|
|
107
|
+
if (scrollElm) {
|
|
108
|
+
scrollElm.style.transition = fixWebKitTransitionStyle;
|
|
109
|
+
if (position) {
|
|
110
|
+
var viewPortElm = scrollElm.firstChild;
|
|
111
|
+
if (viewPortElm) {
|
|
112
|
+
viewPortElm.style.position = position;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -15,7 +15,7 @@ import { isElmEqualOrContain, useTouchMouseEvent, } from '../useTouchMouseEvent'
|
|
|
15
15
|
export var useLongPress = function (_a, _b, _c) {
|
|
16
16
|
var onTap = _a.onTap, onPress = _a.onPress;
|
|
17
17
|
var _d = _b === void 0 ? {} : _b, onTouchStart = _d.onTouchStart, onTouchEnd = _d.onTouchEnd, onMouseDown = _d.onMouseDown, onKeyDown = _d.onKeyDown, onKeyUp = _d.onKeyUp, onContextMenu = _d.onContextMenu, onMouseUpArg = _d.onMouseUp;
|
|
18
|
-
var _e = _c === void 0 ? {} : _c, _f = _e.isPreventDefault, isPreventDefault = _f === void 0 ? true : _f, _g = _e.delay, delay = _g === void 0 ? 300 : _g;
|
|
18
|
+
var _e = _c === void 0 ? {} : _c, _f = _e.isPreventDefault, isPreventDefault = _f === void 0 ? true : _f, _g = _e.delay, delay = _g === void 0 ? 300 : _g, _h = _e.externalWindow, externalWindow = _h === void 0 ? window : _h;
|
|
19
19
|
var isEmittedRef = useRef(false);
|
|
20
20
|
var isA11yDownRef = useRef(false);
|
|
21
21
|
var elmRef = useRef(null);
|
|
@@ -29,7 +29,7 @@ export var useLongPress = function (_a, _b, _c) {
|
|
|
29
29
|
}, delay);
|
|
30
30
|
var end = function (e) {
|
|
31
31
|
// ! mouse up only trigger when up on element, so we host that in document
|
|
32
|
-
document.removeEventListener('mouseup', onMouseUp);
|
|
32
|
+
externalWindow.document.removeEventListener('mouseup', onMouseUp);
|
|
33
33
|
if (!isEmittedRef.current && isElmEqualOrContain(e.target, elmRef)) {
|
|
34
34
|
onTap === null || onTap === void 0 ? void 0 : onTap(e, reasonRef.current);
|
|
35
35
|
}
|
|
@@ -39,7 +39,7 @@ export var useLongPress = function (_a, _b, _c) {
|
|
|
39
39
|
};
|
|
40
40
|
var start = function (e) {
|
|
41
41
|
// ! mouse up only trigger when up on element, so we host that in document
|
|
42
|
-
document.addEventListener('mouseup', onMouseUp);
|
|
42
|
+
externalWindow.document.addEventListener('mouseup', onMouseUp);
|
|
43
43
|
var isTouch = e.type === 'touchstart';
|
|
44
44
|
if (!isTouch)
|
|
45
45
|
e.preventDefault();
|
|
@@ -49,7 +49,7 @@ export var useLongPress = function (_a, _b, _c) {
|
|
|
49
49
|
}
|
|
50
50
|
emitLongPress(e);
|
|
51
51
|
};
|
|
52
|
-
var
|
|
52
|
+
var _j = useTouchMouseEvent({
|
|
53
53
|
onTouchStart: function (e) {
|
|
54
54
|
onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(e);
|
|
55
55
|
start(e);
|
|
@@ -66,7 +66,7 @@ export var useLongPress = function (_a, _b, _c) {
|
|
|
66
66
|
onMouseUpArg === null || onMouseUpArg === void 0 ? void 0 : onMouseUpArg(e);
|
|
67
67
|
end(e);
|
|
68
68
|
},
|
|
69
|
-
}, { isPreventDefault: isPreventDefault }), onMouseUp =
|
|
69
|
+
}, { isPreventDefault: isPreventDefault }), onMouseUp = _j.onMouseUp, events = __rest(_j, ["onMouseUp"]);
|
|
70
70
|
var handleDeleteKeyDown = useA11yKeyEvent(function (e) {
|
|
71
71
|
reasonRef.current = 'keyboard';
|
|
72
72
|
// * keydown when hold will trigger many time, show when current is a11y down, not trigger again
|
|
@@ -92,8 +92,8 @@ export var useLongPress = function (_a, _b, _c) {
|
|
|
92
92
|
useEffect(function () {
|
|
93
93
|
return function () {
|
|
94
94
|
// * clean when in start remove
|
|
95
|
-
document.removeEventListener('mouseup', onMouseUp);
|
|
95
|
+
externalWindow.document.removeEventListener('mouseup', onMouseUp);
|
|
96
96
|
};
|
|
97
|
-
}, [onMouseUp]);
|
|
97
|
+
}, [onMouseUp, externalWindow]);
|
|
98
98
|
return __assign({ ref: elmRef, onContextMenu: handleContextMenu, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }, events);
|
|
99
99
|
};
|