@digipair/skill-web-spectrum 0.89.0 → 0.91.0-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/.swcrc +28 -0
- package/README.md +7 -0
- package/eslint.config.mjs +22 -0
- package/package.json +21 -5
- package/rollup.config.cjs +28 -0
- package/src/lib/skill-web-spectrum.spec.ts +7 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +19 -0
- package/flow.cjs.js +0 -1257
- package/flow.esm.js +0 -1254
- package/focus-visible.cjs.js +0 -289
- package/focus-visible.esm.js +0 -287
- package/index.cjs.d.ts +0 -1
- package/index.cjs.js +0 -59491
- package/index.esm.js +0 -59489
- /package/{index.d.ts → src/index.d.ts} +0 -0
- /package/{libs/skill-web-spectrum/src/index.d.ts → src/index.ts} +0 -0
- /package/{libs/skill-web-spectrum/src/lib/skill-web-spectrum.d.ts → src/lib/skill-web-spectrum.ts} +0 -0
- /package/{schema.fr.json → src/schema.fr.json} +0 -0
- /package/{schema.json → src/schema.json} +0 -0
package/flow.esm.js
DELETED
|
@@ -1,1254 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/ function _class_call_check$2(instance, Constructor) {
|
|
6
|
-
if (!(instance instanceof Constructor)) {
|
|
7
|
-
throw new TypeError("Cannot call a class as a function");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function _defineProperties$2(target, props) {
|
|
11
|
-
for(var i = 0; i < props.length; i++){
|
|
12
|
-
var descriptor = props[i];
|
|
13
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14
|
-
descriptor.configurable = true;
|
|
15
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
16
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function _create_class$2(Constructor, protoProps, staticProps) {
|
|
20
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
21
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
22
|
-
return Constructor;
|
|
23
|
-
}
|
|
24
|
-
var SizeCache = /*#__PURE__*/ function() {
|
|
25
|
-
function SizeCache(config) {
|
|
26
|
-
_class_call_check$2(this, SizeCache);
|
|
27
|
-
this._map = new Map();
|
|
28
|
-
this._roundAverageSize = false;
|
|
29
|
-
this.totalSize = 0;
|
|
30
|
-
if ((config === null || config === void 0 ? void 0 : config.roundAverageSize) === true) {
|
|
31
|
-
this._roundAverageSize = true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
_create_class$2(SizeCache, [
|
|
35
|
-
{
|
|
36
|
-
key: "set",
|
|
37
|
-
value: function set(index, value) {
|
|
38
|
-
var prev = this._map.get(index) || 0;
|
|
39
|
-
this._map.set(index, value);
|
|
40
|
-
this.totalSize += value - prev;
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
key: "averageSize",
|
|
45
|
-
get: function get() {
|
|
46
|
-
if (this._map.size > 0) {
|
|
47
|
-
var average = this.totalSize / this._map.size;
|
|
48
|
-
return this._roundAverageSize ? Math.round(average) : average;
|
|
49
|
-
}
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
key: "getSize",
|
|
55
|
-
value: function getSize(index) {
|
|
56
|
-
return this._map.get(index);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
key: "clear",
|
|
61
|
-
value: function clear() {
|
|
62
|
-
this._map.clear();
|
|
63
|
-
this.totalSize = 0;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
]);
|
|
67
|
-
return SizeCache;
|
|
68
|
-
}
|
|
69
|
-
();
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @license
|
|
73
|
-
* Copyright 2021 Google LLC
|
|
74
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
75
|
-
*/ function _class_call_check$1(instance, Constructor) {
|
|
76
|
-
if (!(instance instanceof Constructor)) {
|
|
77
|
-
throw new TypeError("Cannot call a class as a function");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function _defineProperties$1(target, props) {
|
|
81
|
-
for(var i = 0; i < props.length; i++){
|
|
82
|
-
var descriptor = props[i];
|
|
83
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
84
|
-
descriptor.configurable = true;
|
|
85
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
86
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
90
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
91
|
-
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
92
|
-
return Constructor;
|
|
93
|
-
}
|
|
94
|
-
function _define_property$1(obj, key, value) {
|
|
95
|
-
if (key in obj) {
|
|
96
|
-
Object.defineProperty(obj, key, {
|
|
97
|
-
value: value,
|
|
98
|
-
enumerable: true,
|
|
99
|
-
configurable: true,
|
|
100
|
-
writable: true
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
obj[key] = value;
|
|
104
|
-
}
|
|
105
|
-
return obj;
|
|
106
|
-
}
|
|
107
|
-
function dim1(direction) {
|
|
108
|
-
return direction === "horizontal" ? "width" : "height";
|
|
109
|
-
}
|
|
110
|
-
var BaseLayout = /*#__PURE__*/ function() {
|
|
111
|
-
function BaseLayout(hostSink, config) {
|
|
112
|
-
var _this = this;
|
|
113
|
-
_class_call_check$1(this, BaseLayout);
|
|
114
|
-
/**
|
|
115
|
-
* The last set viewport scroll position.
|
|
116
|
-
*/ this._latestCoords = {
|
|
117
|
-
left: 0,
|
|
118
|
-
top: 0
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Scrolling direction.
|
|
122
|
-
*/ this._direction = null;
|
|
123
|
-
/**
|
|
124
|
-
* Dimensions of the viewport.
|
|
125
|
-
*/ this._viewportSize = {
|
|
126
|
-
width: 0,
|
|
127
|
-
height: 0
|
|
128
|
-
};
|
|
129
|
-
this.totalScrollSize = {
|
|
130
|
-
width: 0,
|
|
131
|
-
height: 0
|
|
132
|
-
};
|
|
133
|
-
this.offsetWithinScroller = {
|
|
134
|
-
left: 0,
|
|
135
|
-
top: 0
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Flag for debouncing asynchronous reflow requests.
|
|
139
|
-
*/ this._pendingReflow = false;
|
|
140
|
-
this._pendingLayoutUpdate = false;
|
|
141
|
-
this._pin = null;
|
|
142
|
-
/**
|
|
143
|
-
* The index of the first item intersecting the viewport.
|
|
144
|
-
*/ this._firstVisible = 0;
|
|
145
|
-
/**
|
|
146
|
-
* The index of the last item intersecting the viewport.
|
|
147
|
-
*/ this._lastVisible = 0;
|
|
148
|
-
/**
|
|
149
|
-
* Pixel offset in the scroll direction of the first child.
|
|
150
|
-
*/ this._physicalMin = 0;
|
|
151
|
-
/**
|
|
152
|
-
* Pixel offset in the scroll direction of the last child.
|
|
153
|
-
*/ this._physicalMax = 0;
|
|
154
|
-
/**
|
|
155
|
-
* Index of the first child.
|
|
156
|
-
*/ this._first = -1;
|
|
157
|
-
/**
|
|
158
|
-
* Index of the last child.
|
|
159
|
-
*/ this._last = -1;
|
|
160
|
-
/**
|
|
161
|
-
* Length in the scrolling direction.
|
|
162
|
-
*/ this._sizeDim = "height";
|
|
163
|
-
/**
|
|
164
|
-
* Length in the non-scrolling direction.
|
|
165
|
-
*/ this._secondarySizeDim = "width";
|
|
166
|
-
/**
|
|
167
|
-
* Position in the scrolling direction.
|
|
168
|
-
*/ this._positionDim = "top";
|
|
169
|
-
/**
|
|
170
|
-
* Position in the non-scrolling direction.
|
|
171
|
-
*/ this._secondaryPositionDim = "left";
|
|
172
|
-
/**
|
|
173
|
-
* Current scroll offset in pixels.
|
|
174
|
-
*/ this._scrollPosition = 0;
|
|
175
|
-
/**
|
|
176
|
-
* Difference between current scroll offset and scroll offset calculated due
|
|
177
|
-
* to a reflow.
|
|
178
|
-
*/ this._scrollError = 0;
|
|
179
|
-
/**
|
|
180
|
-
* Total number of items that could possibly be displayed. Used to help
|
|
181
|
-
* calculate the scroll size.
|
|
182
|
-
*/ this._items = [];
|
|
183
|
-
/**
|
|
184
|
-
* The total (estimated) length of all items in the scrolling direction.
|
|
185
|
-
*/ this._scrollSize = 1;
|
|
186
|
-
/**
|
|
187
|
-
* Number of pixels beyond the viewport to still include
|
|
188
|
-
* in the active range of items.
|
|
189
|
-
*/ // TODO (graynorton): Probably want to make this something we calculate based
|
|
190
|
-
// on viewport size, item size, other factors, possibly still with a dial of some kind
|
|
191
|
-
this._overhang = 1000;
|
|
192
|
-
this._hostSink = hostSink;
|
|
193
|
-
// Delay setting config so that subclasses do setup work first
|
|
194
|
-
Promise.resolve().then(function() {
|
|
195
|
-
return _this.config = config || _this._getDefaultConfig();
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
_create_class$1(BaseLayout, [
|
|
199
|
-
{
|
|
200
|
-
key: "_getDefaultConfig",
|
|
201
|
-
value: function _getDefaultConfig() {
|
|
202
|
-
return {
|
|
203
|
-
direction: "vertical"
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
key: "config",
|
|
209
|
-
get: function get() {
|
|
210
|
-
return {
|
|
211
|
-
direction: this.direction
|
|
212
|
-
};
|
|
213
|
-
},
|
|
214
|
-
set: function set(config) {
|
|
215
|
-
Object.assign(this, Object.assign({}, this._getDefaultConfig(), config));
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
key: "items",
|
|
220
|
-
get: /**
|
|
221
|
-
* Maximum index of children + 1, to help estimate total height of the scroll
|
|
222
|
-
* space.
|
|
223
|
-
*/ function get() {
|
|
224
|
-
return this._items;
|
|
225
|
-
},
|
|
226
|
-
set: function set(items) {
|
|
227
|
-
this._setItems(items);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
key: "_setItems",
|
|
232
|
-
value: function _setItems(items) {
|
|
233
|
-
if (items !== this._items) {
|
|
234
|
-
this._items = items;
|
|
235
|
-
this._scheduleReflow();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
key: "direction",
|
|
241
|
-
get: /**
|
|
242
|
-
* Primary scrolling direction.
|
|
243
|
-
*/ function get() {
|
|
244
|
-
return this._direction;
|
|
245
|
-
},
|
|
246
|
-
set: function set(dir) {
|
|
247
|
-
// Force it to be either horizontal or vertical.
|
|
248
|
-
dir = dir === "horizontal" ? dir : "vertical";
|
|
249
|
-
if (dir !== this._direction) {
|
|
250
|
-
this._direction = dir;
|
|
251
|
-
this._sizeDim = dir === "horizontal" ? "width" : "height";
|
|
252
|
-
this._secondarySizeDim = dir === "horizontal" ? "height" : "width";
|
|
253
|
-
this._positionDim = dir === "horizontal" ? "left" : "top";
|
|
254
|
-
this._secondaryPositionDim = dir === "horizontal" ? "top" : "left";
|
|
255
|
-
this._triggerReflow();
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
key: "viewportSize",
|
|
261
|
-
get: /**
|
|
262
|
-
* Height and width of the viewport.
|
|
263
|
-
*/ function get() {
|
|
264
|
-
return this._viewportSize;
|
|
265
|
-
},
|
|
266
|
-
set: function set(dims) {
|
|
267
|
-
var _this = this, _viewDim1 = _this._viewDim1, _viewDim2 = _this._viewDim2;
|
|
268
|
-
Object.assign(this._viewportSize, dims);
|
|
269
|
-
if (_viewDim2 !== this._viewDim2) {
|
|
270
|
-
// this._viewDim2Changed();
|
|
271
|
-
this._scheduleLayoutUpdate();
|
|
272
|
-
} else if (_viewDim1 !== this._viewDim1) {
|
|
273
|
-
this._checkThresholds();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
key: "viewportScroll",
|
|
279
|
-
get: /**
|
|
280
|
-
* Scroll offset of the viewport.
|
|
281
|
-
*/ function get() {
|
|
282
|
-
return this._latestCoords;
|
|
283
|
-
},
|
|
284
|
-
set: function set(coords) {
|
|
285
|
-
Object.assign(this._latestCoords, coords);
|
|
286
|
-
var oldPos = this._scrollPosition;
|
|
287
|
-
this._scrollPosition = this._latestCoords[this._positionDim];
|
|
288
|
-
var change = Math.abs(oldPos - this._scrollPosition);
|
|
289
|
-
if (change >= 1) {
|
|
290
|
-
this._checkThresholds();
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
/**
|
|
296
|
-
* Perform a reflow if one has been scheduled.
|
|
297
|
-
*/ key: "reflowIfNeeded",
|
|
298
|
-
value: function reflowIfNeeded() {
|
|
299
|
-
var force = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
300
|
-
if (force || this._pendingReflow) {
|
|
301
|
-
this._pendingReflow = false;
|
|
302
|
-
this._reflow();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
key: "pin",
|
|
308
|
-
get: function get() {
|
|
309
|
-
if (this._pin !== null) {
|
|
310
|
-
var _this__pin = this._pin, index = _this__pin.index, block = _this__pin.block;
|
|
311
|
-
return {
|
|
312
|
-
index: Math.max(0, Math.min(index, this.items.length - 1)),
|
|
313
|
-
block: block
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
return null;
|
|
317
|
-
},
|
|
318
|
-
set: function set(options) {
|
|
319
|
-
this._pin = options;
|
|
320
|
-
this._triggerReflow();
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
key: "_clampScrollPosition",
|
|
325
|
-
value: function _clampScrollPosition(val) {
|
|
326
|
-
return Math.max(-this.offsetWithinScroller[this._positionDim], Math.min(val, this.totalScrollSize[dim1(this.direction)] - this._viewDim1));
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
key: "unpin",
|
|
331
|
-
value: function unpin() {
|
|
332
|
-
if (this._pin !== null) {
|
|
333
|
-
this._sendUnpinnedMessage();
|
|
334
|
-
this._pin = null;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
key: "_updateLayout",
|
|
340
|
-
value: function _updateLayout() {
|
|
341
|
-
// Override
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
key: "_viewDim1",
|
|
346
|
-
get: // protected _viewDim2Changed(): void {
|
|
347
|
-
// this._scheduleLayoutUpdate();
|
|
348
|
-
// }
|
|
349
|
-
/**
|
|
350
|
-
* The height or width of the viewport, whichever corresponds to the scrolling direction.
|
|
351
|
-
*/ function get() {
|
|
352
|
-
return this._viewportSize[this._sizeDim];
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
key: "_viewDim2",
|
|
357
|
-
get: /**
|
|
358
|
-
* The height or width of the viewport, whichever does NOT correspond to the scrolling direction.
|
|
359
|
-
*/ function get() {
|
|
360
|
-
return this._viewportSize[this._secondarySizeDim];
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
key: "_scheduleReflow",
|
|
365
|
-
value: function _scheduleReflow() {
|
|
366
|
-
this._pendingReflow = true;
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
key: "_scheduleLayoutUpdate",
|
|
371
|
-
value: function _scheduleLayoutUpdate() {
|
|
372
|
-
this._pendingLayoutUpdate = true;
|
|
373
|
-
this._scheduleReflow();
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
// For triggering a reflow based on incoming changes to
|
|
378
|
-
// the layout config.
|
|
379
|
-
key: "_triggerReflow",
|
|
380
|
-
value: function _triggerReflow() {
|
|
381
|
-
var _this = this;
|
|
382
|
-
this._scheduleLayoutUpdate();
|
|
383
|
-
// TODO graynorton@: reflowIfNeeded() isn't really supposed
|
|
384
|
-
// to be called internally. Address in larger cleanup
|
|
385
|
-
// of virtualizer / layout interaction pattern.
|
|
386
|
-
// this.reflowIfNeeded(true);
|
|
387
|
-
Promise.resolve().then(function() {
|
|
388
|
-
return _this.reflowIfNeeded();
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
key: "_reflow",
|
|
394
|
-
value: function _reflow() {
|
|
395
|
-
if (this._pendingLayoutUpdate) {
|
|
396
|
-
this._updateLayout();
|
|
397
|
-
this._pendingLayoutUpdate = false;
|
|
398
|
-
}
|
|
399
|
-
this._updateScrollSize();
|
|
400
|
-
this._setPositionFromPin();
|
|
401
|
-
this._getActiveItems();
|
|
402
|
-
this._updateVisibleIndices();
|
|
403
|
-
this._sendStateChangedMessage();
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
/**
|
|
408
|
-
* If we are supposed to be pinned to a particular
|
|
409
|
-
* item or set of coordinates, we set `_scrollPosition`
|
|
410
|
-
* accordingly and adjust `_scrollError` as needed
|
|
411
|
-
* so that the virtualizer can keep the scroll
|
|
412
|
-
* position in the DOM in sync
|
|
413
|
-
*/ key: "_setPositionFromPin",
|
|
414
|
-
value: function _setPositionFromPin() {
|
|
415
|
-
if (this.pin !== null) {
|
|
416
|
-
var lastScrollPosition = this._scrollPosition;
|
|
417
|
-
var _this_pin = this.pin, index = _this_pin.index, block = _this_pin.block;
|
|
418
|
-
this._scrollPosition = this._calculateScrollIntoViewPosition({
|
|
419
|
-
index: index,
|
|
420
|
-
block: block || "start"
|
|
421
|
-
}) - this.offsetWithinScroller[this._positionDim];
|
|
422
|
-
this._scrollError = lastScrollPosition - this._scrollPosition;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
/**
|
|
428
|
-
* Calculate the coordinates to scroll to, given
|
|
429
|
-
* a request to scroll to the element at a specific
|
|
430
|
-
* index.
|
|
431
|
-
*
|
|
432
|
-
* Supports the same positioning options (`start`,
|
|
433
|
-
* `center`, `end`, `nearest`) as the standard
|
|
434
|
-
* `Element.scrollIntoView()` method, but currently
|
|
435
|
-
* only considers the provided value in the `block`
|
|
436
|
-
* dimension, since we don't yet have any layouts
|
|
437
|
-
* that support virtualization in two dimensions.
|
|
438
|
-
*/ key: "_calculateScrollIntoViewPosition",
|
|
439
|
-
value: function _calculateScrollIntoViewPosition(options) {
|
|
440
|
-
var block = options.block;
|
|
441
|
-
var index = Math.min(this.items.length, Math.max(0, options.index));
|
|
442
|
-
var itemStartPosition = this._getItemPosition(index)[this._positionDim];
|
|
443
|
-
var scrollPosition = itemStartPosition;
|
|
444
|
-
if (block !== "start") {
|
|
445
|
-
var itemSize = this._getItemSize(index)[this._sizeDim];
|
|
446
|
-
if (block === "center") {
|
|
447
|
-
scrollPosition = itemStartPosition - 0.5 * this._viewDim1 + 0.5 * itemSize;
|
|
448
|
-
} else {
|
|
449
|
-
var itemEndPosition = itemStartPosition - this._viewDim1 + itemSize;
|
|
450
|
-
if (block === "end") {
|
|
451
|
-
scrollPosition = itemEndPosition;
|
|
452
|
-
} else {
|
|
453
|
-
// block === 'nearest'
|
|
454
|
-
var currentScrollPosition = this._scrollPosition;
|
|
455
|
-
scrollPosition = Math.abs(currentScrollPosition - itemStartPosition) < Math.abs(currentScrollPosition - itemEndPosition) ? itemStartPosition : itemEndPosition;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
scrollPosition += this.offsetWithinScroller[this._positionDim];
|
|
460
|
-
return this._clampScrollPosition(scrollPosition);
|
|
461
|
-
}
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
key: "getScrollIntoViewCoordinates",
|
|
465
|
-
value: function getScrollIntoViewCoordinates(options) {
|
|
466
|
-
return _define_property$1({}, this._positionDim, this._calculateScrollIntoViewPosition(options));
|
|
467
|
-
}
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
key: "_sendUnpinnedMessage",
|
|
471
|
-
value: function _sendUnpinnedMessage() {
|
|
472
|
-
this._hostSink({
|
|
473
|
-
type: "unpinned"
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
key: "_sendVisibilityChangedMessage",
|
|
479
|
-
value: function _sendVisibilityChangedMessage() {
|
|
480
|
-
this._hostSink({
|
|
481
|
-
type: "visibilityChanged",
|
|
482
|
-
firstVisible: this._firstVisible,
|
|
483
|
-
lastVisible: this._lastVisible
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
key: "_sendStateChangedMessage",
|
|
489
|
-
value: function _sendStateChangedMessage() {
|
|
490
|
-
var childPositions = new Map();
|
|
491
|
-
if (this._first !== -1 && this._last !== -1) {
|
|
492
|
-
for(var idx = this._first; idx <= this._last; idx++){
|
|
493
|
-
childPositions.set(idx, this._getItemPosition(idx));
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
var _obj;
|
|
497
|
-
var message = {
|
|
498
|
-
type: "stateChanged",
|
|
499
|
-
scrollSize: (_obj = {}, _define_property$1(_obj, this._sizeDim, this._scrollSize), _define_property$1(_obj, this._secondarySizeDim, null), _obj),
|
|
500
|
-
range: {
|
|
501
|
-
first: this._first,
|
|
502
|
-
last: this._last,
|
|
503
|
-
firstVisible: this._firstVisible,
|
|
504
|
-
lastVisible: this._lastVisible
|
|
505
|
-
},
|
|
506
|
-
childPositions: childPositions
|
|
507
|
-
};
|
|
508
|
-
if (this._scrollError) {
|
|
509
|
-
var _obj1;
|
|
510
|
-
message.scrollError = (_obj1 = {}, _define_property$1(_obj1, this._positionDim, this._scrollError), _define_property$1(_obj1, this._secondaryPositionDim, 0), _obj1);
|
|
511
|
-
this._scrollError = 0;
|
|
512
|
-
}
|
|
513
|
-
this._hostSink(message);
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
key: "_num",
|
|
518
|
-
get: /**
|
|
519
|
-
* Number of items to display.
|
|
520
|
-
*/ function get() {
|
|
521
|
-
if (this._first === -1 || this._last === -1) {
|
|
522
|
-
return 0;
|
|
523
|
-
}
|
|
524
|
-
return this._last - this._first + 1;
|
|
525
|
-
}
|
|
526
|
-
},
|
|
527
|
-
{
|
|
528
|
-
key: "_checkThresholds",
|
|
529
|
-
value: function _checkThresholds() {
|
|
530
|
-
if (this._viewDim1 === 0 && this._num > 0 || this._pin !== null) {
|
|
531
|
-
this._scheduleReflow();
|
|
532
|
-
} else {
|
|
533
|
-
var min = Math.max(0, this._scrollPosition - this._overhang);
|
|
534
|
-
var max = Math.min(this._scrollSize, this._scrollPosition + this._viewDim1 + this._overhang);
|
|
535
|
-
if (this._physicalMin > min || this._physicalMax < max) {
|
|
536
|
-
this._scheduleReflow();
|
|
537
|
-
} else {
|
|
538
|
-
this._updateVisibleIndices({
|
|
539
|
-
emit: true
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
/**
|
|
547
|
-
* Find the indices of the first and last items to intersect the viewport.
|
|
548
|
-
* Emit a visibleindiceschange event when either index changes.
|
|
549
|
-
*/ key: "_updateVisibleIndices",
|
|
550
|
-
value: function _updateVisibleIndices(options) {
|
|
551
|
-
if (this._first === -1 || this._last === -1) return;
|
|
552
|
-
var firstVisible = this._first;
|
|
553
|
-
while(firstVisible < this._last && Math.round(this._getItemPosition(firstVisible)[this._positionDim] + this._getItemSize(firstVisible)[this._sizeDim]) <= Math.round(this._scrollPosition)){
|
|
554
|
-
firstVisible++;
|
|
555
|
-
}
|
|
556
|
-
var lastVisible = this._last;
|
|
557
|
-
while(lastVisible > this._first && Math.round(this._getItemPosition(lastVisible)[this._positionDim]) >= Math.round(this._scrollPosition + this._viewDim1)){
|
|
558
|
-
lastVisible--;
|
|
559
|
-
}
|
|
560
|
-
if (firstVisible !== this._firstVisible || lastVisible !== this._lastVisible) {
|
|
561
|
-
this._firstVisible = firstVisible;
|
|
562
|
-
this._lastVisible = lastVisible;
|
|
563
|
-
if (options && options.emit) {
|
|
564
|
-
this._sendVisibilityChangedMessage();
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
]);
|
|
570
|
-
return BaseLayout;
|
|
571
|
-
}
|
|
572
|
-
();
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* @license
|
|
576
|
-
* Copyright 2021 Google LLC
|
|
577
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
578
|
-
*/ function _array_like_to_array(arr, len) {
|
|
579
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
580
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
581
|
-
return arr2;
|
|
582
|
-
}
|
|
583
|
-
function _array_without_holes(arr) {
|
|
584
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
585
|
-
}
|
|
586
|
-
function _assert_this_initialized(self) {
|
|
587
|
-
if (self === void 0) {
|
|
588
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
589
|
-
}
|
|
590
|
-
return self;
|
|
591
|
-
}
|
|
592
|
-
function _class_call_check(instance, Constructor) {
|
|
593
|
-
if (!(instance instanceof Constructor)) {
|
|
594
|
-
throw new TypeError("Cannot call a class as a function");
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
function _defineProperties(target, props) {
|
|
598
|
-
for(var i = 0; i < props.length; i++){
|
|
599
|
-
var descriptor = props[i];
|
|
600
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
601
|
-
descriptor.configurable = true;
|
|
602
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
603
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
607
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
608
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
609
|
-
return Constructor;
|
|
610
|
-
}
|
|
611
|
-
function _define_property(obj, key, value) {
|
|
612
|
-
if (key in obj) {
|
|
613
|
-
Object.defineProperty(obj, key, {
|
|
614
|
-
value: value,
|
|
615
|
-
enumerable: true,
|
|
616
|
-
configurable: true,
|
|
617
|
-
writable: true
|
|
618
|
-
});
|
|
619
|
-
} else {
|
|
620
|
-
obj[key] = value;
|
|
621
|
-
}
|
|
622
|
-
return obj;
|
|
623
|
-
}
|
|
624
|
-
function _get(target, property, receiver) {
|
|
625
|
-
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
626
|
-
_get = Reflect.get;
|
|
627
|
-
} else {
|
|
628
|
-
_get = function get(target, property, receiver) {
|
|
629
|
-
var base = _super_prop_base(target, property);
|
|
630
|
-
if (!base) return;
|
|
631
|
-
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
632
|
-
if (desc.get) {
|
|
633
|
-
return desc.get.call(receiver || target);
|
|
634
|
-
}
|
|
635
|
-
return desc.value;
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
return _get(target, property, receiver || target);
|
|
639
|
-
}
|
|
640
|
-
function _get_prototype_of(o) {
|
|
641
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
642
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
643
|
-
};
|
|
644
|
-
return _get_prototype_of(o);
|
|
645
|
-
}
|
|
646
|
-
function _inherits(subClass, superClass) {
|
|
647
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
648
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
649
|
-
}
|
|
650
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
651
|
-
constructor: {
|
|
652
|
-
value: subClass,
|
|
653
|
-
writable: true,
|
|
654
|
-
configurable: true
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
658
|
-
}
|
|
659
|
-
function _iterable_to_array(iter) {
|
|
660
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
661
|
-
}
|
|
662
|
-
function _non_iterable_spread() {
|
|
663
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
664
|
-
}
|
|
665
|
-
function _possible_constructor_return(self, call) {
|
|
666
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
667
|
-
return call;
|
|
668
|
-
}
|
|
669
|
-
return _assert_this_initialized(self);
|
|
670
|
-
}
|
|
671
|
-
function _set_prototype_of(o, p) {
|
|
672
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
673
|
-
o.__proto__ = p;
|
|
674
|
-
return o;
|
|
675
|
-
};
|
|
676
|
-
return _set_prototype_of(o, p);
|
|
677
|
-
}
|
|
678
|
-
function _super_prop_base(object, property) {
|
|
679
|
-
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
680
|
-
object = _get_prototype_of(object);
|
|
681
|
-
if (object === null) break;
|
|
682
|
-
}
|
|
683
|
-
return object;
|
|
684
|
-
}
|
|
685
|
-
function _to_consumable_array(arr) {
|
|
686
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
687
|
-
}
|
|
688
|
-
function _type_of(obj) {
|
|
689
|
-
"@swc/helpers - typeof";
|
|
690
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
691
|
-
}
|
|
692
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
693
|
-
if (!o) return;
|
|
694
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
695
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
696
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
697
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
698
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
699
|
-
}
|
|
700
|
-
function _is_native_reflect_construct() {
|
|
701
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
702
|
-
if (Reflect.construct.sham) return false;
|
|
703
|
-
if (typeof Proxy === "function") return true;
|
|
704
|
-
try {
|
|
705
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
706
|
-
return true;
|
|
707
|
-
} catch (e) {
|
|
708
|
-
return false;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
function _create_super(Derived) {
|
|
712
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
713
|
-
return function _createSuperInternal() {
|
|
714
|
-
var Super = _get_prototype_of(Derived), result;
|
|
715
|
-
if (hasNativeReflectConstruct) {
|
|
716
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
717
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
718
|
-
} else {
|
|
719
|
-
result = Super.apply(this, arguments);
|
|
720
|
-
}
|
|
721
|
-
return _possible_constructor_return(this, result);
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
var flow = function(config) {
|
|
725
|
-
return Object.assign({
|
|
726
|
-
type: FlowLayout
|
|
727
|
-
}, config);
|
|
728
|
-
};
|
|
729
|
-
function leadingMargin(direction) {
|
|
730
|
-
return direction === "horizontal" ? "marginLeft" : "marginTop";
|
|
731
|
-
}
|
|
732
|
-
function trailingMargin(direction) {
|
|
733
|
-
return direction === "horizontal" ? "marginRight" : "marginBottom";
|
|
734
|
-
}
|
|
735
|
-
function offset(direction) {
|
|
736
|
-
return direction === "horizontal" ? "xOffset" : "yOffset";
|
|
737
|
-
}
|
|
738
|
-
function collapseMargins(a, b) {
|
|
739
|
-
var _Math, _Math1;
|
|
740
|
-
var m = [
|
|
741
|
-
a,
|
|
742
|
-
b
|
|
743
|
-
].sort();
|
|
744
|
-
return m[1] <= 0 ? (_Math = Math).min.apply(_Math, _to_consumable_array(m)) : m[0] >= 0 ? (_Math1 = Math).max.apply(_Math1, _to_consumable_array(m)) : m[0] + m[1];
|
|
745
|
-
}
|
|
746
|
-
var MetricsCache = /*#__PURE__*/ function() {
|
|
747
|
-
function MetricsCache() {
|
|
748
|
-
_class_call_check(this, MetricsCache);
|
|
749
|
-
this._childSizeCache = new SizeCache();
|
|
750
|
-
this._marginSizeCache = new SizeCache();
|
|
751
|
-
this._metricsCache = new Map();
|
|
752
|
-
}
|
|
753
|
-
_create_class(MetricsCache, [
|
|
754
|
-
{
|
|
755
|
-
key: "update",
|
|
756
|
-
value: function update(metrics, direction) {
|
|
757
|
-
var _this = this;
|
|
758
|
-
var marginsToUpdate = new Set();
|
|
759
|
-
Object.keys(metrics).forEach(function(key) {
|
|
760
|
-
var k = Number(key);
|
|
761
|
-
_this._metricsCache.set(k, metrics[k]);
|
|
762
|
-
_this._childSizeCache.set(k, metrics[k][dim1(direction)]);
|
|
763
|
-
marginsToUpdate.add(k);
|
|
764
|
-
marginsToUpdate.add(k + 1);
|
|
765
|
-
});
|
|
766
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
767
|
-
try {
|
|
768
|
-
for(var _iterator = marginsToUpdate[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
769
|
-
var k = _step.value;
|
|
770
|
-
var _this__metricsCache_get, _this__metricsCache_get1;
|
|
771
|
-
var a = ((_this__metricsCache_get = this._metricsCache.get(k)) === null || _this__metricsCache_get === void 0 ? void 0 : _this__metricsCache_get[leadingMargin(direction)]) || 0;
|
|
772
|
-
var b = ((_this__metricsCache_get1 = this._metricsCache.get(k - 1)) === null || _this__metricsCache_get1 === void 0 ? void 0 : _this__metricsCache_get1[trailingMargin(direction)]) || 0;
|
|
773
|
-
this._marginSizeCache.set(k, collapseMargins(a, b));
|
|
774
|
-
}
|
|
775
|
-
} catch (err) {
|
|
776
|
-
_didIteratorError = true;
|
|
777
|
-
_iteratorError = err;
|
|
778
|
-
} finally{
|
|
779
|
-
try {
|
|
780
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
781
|
-
_iterator.return();
|
|
782
|
-
}
|
|
783
|
-
} finally{
|
|
784
|
-
if (_didIteratorError) {
|
|
785
|
-
throw _iteratorError;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
key: "averageChildSize",
|
|
793
|
-
get: function get() {
|
|
794
|
-
return this._childSizeCache.averageSize;
|
|
795
|
-
}
|
|
796
|
-
},
|
|
797
|
-
{
|
|
798
|
-
key: "totalChildSize",
|
|
799
|
-
get: function get() {
|
|
800
|
-
return this._childSizeCache.totalSize;
|
|
801
|
-
}
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
key: "averageMarginSize",
|
|
805
|
-
get: function get() {
|
|
806
|
-
return this._marginSizeCache.averageSize;
|
|
807
|
-
}
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
key: "totalMarginSize",
|
|
811
|
-
get: function get() {
|
|
812
|
-
return this._marginSizeCache.totalSize;
|
|
813
|
-
}
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
key: "getLeadingMarginValue",
|
|
817
|
-
value: function getLeadingMarginValue(index, direction) {
|
|
818
|
-
var _this__metricsCache_get;
|
|
819
|
-
return ((_this__metricsCache_get = this._metricsCache.get(index)) === null || _this__metricsCache_get === void 0 ? void 0 : _this__metricsCache_get[leadingMargin(direction)]) || 0;
|
|
820
|
-
}
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
key: "getChildSize",
|
|
824
|
-
value: function getChildSize(index) {
|
|
825
|
-
return this._childSizeCache.getSize(index);
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
key: "getMarginSize",
|
|
830
|
-
value: function getMarginSize(index) {
|
|
831
|
-
return this._marginSizeCache.getSize(index);
|
|
832
|
-
}
|
|
833
|
-
},
|
|
834
|
-
{
|
|
835
|
-
key: "clear",
|
|
836
|
-
value: function clear() {
|
|
837
|
-
this._childSizeCache.clear();
|
|
838
|
-
this._marginSizeCache.clear();
|
|
839
|
-
this._metricsCache.clear();
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
]);
|
|
843
|
-
return MetricsCache;
|
|
844
|
-
}();
|
|
845
|
-
var FlowLayout = /*#__PURE__*/ function(BaseLayout) {
|
|
846
|
-
_inherits(FlowLayout, BaseLayout);
|
|
847
|
-
var _super = _create_super(FlowLayout);
|
|
848
|
-
function FlowLayout() {
|
|
849
|
-
_class_call_check(this, FlowLayout);
|
|
850
|
-
var _this;
|
|
851
|
-
_this = _super.call.apply(_super, [
|
|
852
|
-
this
|
|
853
|
-
].concat(Array.prototype.slice.call(arguments)));
|
|
854
|
-
/**
|
|
855
|
-
* Initial estimate of item size
|
|
856
|
-
*/ _this._itemSize = {
|
|
857
|
-
width: 100,
|
|
858
|
-
height: 100
|
|
859
|
-
};
|
|
860
|
-
/**
|
|
861
|
-
* Indices of children mapped to their (position and length) in the scrolling
|
|
862
|
-
* direction. Used to keep track of children that are in range.
|
|
863
|
-
*/ _this._physicalItems = new Map();
|
|
864
|
-
/**
|
|
865
|
-
* Used in tandem with _physicalItems to track children in range across
|
|
866
|
-
* reflows.
|
|
867
|
-
*/ _this._newPhysicalItems = new Map();
|
|
868
|
-
/**
|
|
869
|
-
* Width and height of children by their index.
|
|
870
|
-
*/ _this._metricsCache = new MetricsCache();
|
|
871
|
-
/**
|
|
872
|
-
* anchorIdx is the anchor around which we reflow. It is designed to allow
|
|
873
|
-
* jumping to any point of the scroll size. We choose it once and stick with
|
|
874
|
-
* it until stable. _first and _last are deduced around it.
|
|
875
|
-
*/ _this._anchorIdx = null;
|
|
876
|
-
/**
|
|
877
|
-
* Position in the scrolling direction of the anchor child.
|
|
878
|
-
*/ _this._anchorPos = null;
|
|
879
|
-
/**
|
|
880
|
-
* Whether all children in range were in range during the previous reflow.
|
|
881
|
-
*/ _this._stable = true;
|
|
882
|
-
_this._measureChildren = true;
|
|
883
|
-
_this._estimate = true;
|
|
884
|
-
return _this;
|
|
885
|
-
}
|
|
886
|
-
_create_class(FlowLayout, [
|
|
887
|
-
{
|
|
888
|
-
key: "measureChildren",
|
|
889
|
-
get: // protected _defaultConfig: BaseLayoutConfig = Object.assign({}, super._defaultConfig, {
|
|
890
|
-
// })
|
|
891
|
-
// constructor(config: Layout1dConfig) {
|
|
892
|
-
// super(config);
|
|
893
|
-
// }
|
|
894
|
-
function get() {
|
|
895
|
-
return this._measureChildren;
|
|
896
|
-
}
|
|
897
|
-
},
|
|
898
|
-
{
|
|
899
|
-
/**
|
|
900
|
-
* Determine the average size of all children represented in the sizes
|
|
901
|
-
* argument.
|
|
902
|
-
*/ key: "updateItemSizes",
|
|
903
|
-
value: function updateItemSizes(sizes) {
|
|
904
|
-
this._metricsCache.update(sizes, this.direction);
|
|
905
|
-
// if (this._nMeasured) {
|
|
906
|
-
// this._updateItemSize();
|
|
907
|
-
this._scheduleReflow();
|
|
908
|
-
// }
|
|
909
|
-
}
|
|
910
|
-
},
|
|
911
|
-
{
|
|
912
|
-
/**
|
|
913
|
-
* Set the average item size based on the total length and number of children
|
|
914
|
-
* in range.
|
|
915
|
-
*/ // _updateItemSize() {
|
|
916
|
-
// // Keep integer values.
|
|
917
|
-
// this._itemSize[this._sizeDim] = this._metricsCache.averageChildSize;
|
|
918
|
-
// }
|
|
919
|
-
key: "_getPhysicalItem",
|
|
920
|
-
value: function _getPhysicalItem(idx) {
|
|
921
|
-
var _this__newPhysicalItems_get;
|
|
922
|
-
return (_this__newPhysicalItems_get = this._newPhysicalItems.get(idx)) !== null && _this__newPhysicalItems_get !== void 0 ? _this__newPhysicalItems_get : this._physicalItems.get(idx);
|
|
923
|
-
}
|
|
924
|
-
},
|
|
925
|
-
{
|
|
926
|
-
key: "_getSize",
|
|
927
|
-
value: function _getSize(idx) {
|
|
928
|
-
var item = this._getPhysicalItem(idx);
|
|
929
|
-
return item && this._metricsCache.getChildSize(idx);
|
|
930
|
-
}
|
|
931
|
-
},
|
|
932
|
-
{
|
|
933
|
-
key: "_getAverageSize",
|
|
934
|
-
value: function _getAverageSize() {
|
|
935
|
-
return this._metricsCache.averageChildSize || this._itemSize[this._sizeDim];
|
|
936
|
-
}
|
|
937
|
-
},
|
|
938
|
-
{
|
|
939
|
-
key: "_estimatePosition",
|
|
940
|
-
value: function _estimatePosition(idx) {
|
|
941
|
-
var c = this._metricsCache;
|
|
942
|
-
if (this._first === -1 || this._last === -1) {
|
|
943
|
-
return c.averageMarginSize + idx * (c.averageMarginSize + this._getAverageSize());
|
|
944
|
-
} else {
|
|
945
|
-
if (idx < this._first) {
|
|
946
|
-
var delta = this._first - idx;
|
|
947
|
-
var refItem = this._getPhysicalItem(this._first);
|
|
948
|
-
return refItem.pos - (c.getMarginSize(this._first - 1) || c.averageMarginSize) - (delta * c.averageChildSize + (delta - 1) * c.averageMarginSize);
|
|
949
|
-
} else {
|
|
950
|
-
var delta1 = idx - this._last;
|
|
951
|
-
var refItem1 = this._getPhysicalItem(this._last);
|
|
952
|
-
return refItem1.pos + (c.getChildSize(this._last) || c.averageChildSize) + (c.getMarginSize(this._last) || c.averageMarginSize) + delta1 * (c.averageChildSize + c.averageMarginSize);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
},
|
|
957
|
-
{
|
|
958
|
-
/**
|
|
959
|
-
* Returns the position in the scrolling direction of the item at idx.
|
|
960
|
-
* Estimates it if the item at idx is not in the DOM.
|
|
961
|
-
*/ key: "_getPosition",
|
|
962
|
-
value: function _getPosition(idx) {
|
|
963
|
-
var item = this._getPhysicalItem(idx);
|
|
964
|
-
var averageMarginSize = this._metricsCache.averageMarginSize;
|
|
965
|
-
var _this__metricsCache_getMarginSize;
|
|
966
|
-
return idx === 0 ? (_this__metricsCache_getMarginSize = this._metricsCache.getMarginSize(0)) !== null && _this__metricsCache_getMarginSize !== void 0 ? _this__metricsCache_getMarginSize : averageMarginSize : item ? item.pos : this._estimatePosition(idx);
|
|
967
|
-
}
|
|
968
|
-
},
|
|
969
|
-
{
|
|
970
|
-
key: "_calculateAnchor",
|
|
971
|
-
value: function _calculateAnchor(lower, upper) {
|
|
972
|
-
if (lower <= 0) {
|
|
973
|
-
return 0;
|
|
974
|
-
}
|
|
975
|
-
if (upper > this._scrollSize - this._viewDim1) {
|
|
976
|
-
return this.items.length - 1;
|
|
977
|
-
}
|
|
978
|
-
return Math.max(0, Math.min(this.items.length - 1, Math.floor((lower + upper) / 2 / this._delta)));
|
|
979
|
-
}
|
|
980
|
-
},
|
|
981
|
-
{
|
|
982
|
-
key: "_getAnchor",
|
|
983
|
-
value: function _getAnchor(lower, upper) {
|
|
984
|
-
if (this._physicalItems.size === 0) {
|
|
985
|
-
return this._calculateAnchor(lower, upper);
|
|
986
|
-
}
|
|
987
|
-
if (this._first < 0) {
|
|
988
|
-
return this._calculateAnchor(lower, upper);
|
|
989
|
-
}
|
|
990
|
-
if (this._last < 0) {
|
|
991
|
-
return this._calculateAnchor(lower, upper);
|
|
992
|
-
}
|
|
993
|
-
var firstItem = this._getPhysicalItem(this._first), lastItem = this._getPhysicalItem(this._last), firstMin = firstItem.pos, lastMin = lastItem.pos, lastMax = lastMin + this._metricsCache.getChildSize(this._last);
|
|
994
|
-
if (lastMax < lower) {
|
|
995
|
-
// Window is entirely past physical items, calculate new anchor
|
|
996
|
-
return this._calculateAnchor(lower, upper);
|
|
997
|
-
}
|
|
998
|
-
if (firstMin > upper) {
|
|
999
|
-
// Window is entirely before physical items, calculate new anchor
|
|
1000
|
-
return this._calculateAnchor(lower, upper);
|
|
1001
|
-
}
|
|
1002
|
-
// Window contains a physical item
|
|
1003
|
-
// Find one, starting with the one that was previously first visible
|
|
1004
|
-
var candidateIdx = this._firstVisible - 1;
|
|
1005
|
-
var cMax = -Infinity;
|
|
1006
|
-
while(cMax < lower){
|
|
1007
|
-
var candidate = this._getPhysicalItem(++candidateIdx);
|
|
1008
|
-
cMax = candidate.pos + this._metricsCache.getChildSize(candidateIdx);
|
|
1009
|
-
}
|
|
1010
|
-
return candidateIdx;
|
|
1011
|
-
}
|
|
1012
|
-
},
|
|
1013
|
-
{
|
|
1014
|
-
/**
|
|
1015
|
-
* Updates _first and _last based on items that should be in the current
|
|
1016
|
-
* viewed range.
|
|
1017
|
-
*/ key: "_getActiveItems",
|
|
1018
|
-
value: function _getActiveItems() {
|
|
1019
|
-
if (this._viewDim1 === 0 || this.items.length === 0) {
|
|
1020
|
-
this._clearItems();
|
|
1021
|
-
} else {
|
|
1022
|
-
this._getItems();
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
},
|
|
1026
|
-
{
|
|
1027
|
-
/**
|
|
1028
|
-
* Sets the range to empty.
|
|
1029
|
-
*/ key: "_clearItems",
|
|
1030
|
-
value: function _clearItems() {
|
|
1031
|
-
this._first = -1;
|
|
1032
|
-
this._last = -1;
|
|
1033
|
-
this._physicalMin = 0;
|
|
1034
|
-
this._physicalMax = 0;
|
|
1035
|
-
var items = this._newPhysicalItems;
|
|
1036
|
-
this._newPhysicalItems = this._physicalItems;
|
|
1037
|
-
this._newPhysicalItems.clear();
|
|
1038
|
-
this._physicalItems = items;
|
|
1039
|
-
this._stable = true;
|
|
1040
|
-
}
|
|
1041
|
-
},
|
|
1042
|
-
{
|
|
1043
|
-
/*
|
|
1044
|
-
* Updates _first and _last based on items that should be in the given range.
|
|
1045
|
-
*/ key: "_getItems",
|
|
1046
|
-
value: function _getItems() {
|
|
1047
|
-
var items = this._newPhysicalItems;
|
|
1048
|
-
this._stable = true;
|
|
1049
|
-
var lower, upper;
|
|
1050
|
-
// The anchorIdx is the anchor around which we reflow. It is designed to
|
|
1051
|
-
// allow jumping to any point of the scroll size. We choose it once and
|
|
1052
|
-
// stick with it until stable. first and last are deduced around it.
|
|
1053
|
-
// If we have a pinned item, we anchor on it
|
|
1054
|
-
if (this.pin !== null) {
|
|
1055
|
-
var index = this.pin.index;
|
|
1056
|
-
this._anchorIdx = index;
|
|
1057
|
-
this._anchorPos = this._getPosition(index);
|
|
1058
|
-
}
|
|
1059
|
-
// Determine the lower and upper bounds of the region to be
|
|
1060
|
-
// rendered, relative to the viewport
|
|
1061
|
-
lower = this._scrollPosition - this._overhang; //leadingOverhang;
|
|
1062
|
-
upper = this._scrollPosition + this._viewDim1 + this._overhang; // trailingOverhang;
|
|
1063
|
-
if (upper < 0 || lower > this._scrollSize) {
|
|
1064
|
-
this._clearItems();
|
|
1065
|
-
return;
|
|
1066
|
-
}
|
|
1067
|
-
// If we are scrolling to a specific index or if we are doing another
|
|
1068
|
-
// pass to stabilize a previously started reflow, we will already
|
|
1069
|
-
// have an anchor. If not, establish an anchor now.
|
|
1070
|
-
if (this._anchorIdx === null || this._anchorPos === null) {
|
|
1071
|
-
this._anchorIdx = this._getAnchor(lower, upper);
|
|
1072
|
-
this._anchorPos = this._getPosition(this._anchorIdx);
|
|
1073
|
-
}
|
|
1074
|
-
var anchorSize = this._getSize(this._anchorIdx);
|
|
1075
|
-
if (anchorSize === undefined) {
|
|
1076
|
-
this._stable = false;
|
|
1077
|
-
anchorSize = this._getAverageSize();
|
|
1078
|
-
}
|
|
1079
|
-
var _this__metricsCache_getMarginSize;
|
|
1080
|
-
var anchorLeadingMargin = (_this__metricsCache_getMarginSize = this._metricsCache.getMarginSize(this._anchorIdx)) !== null && _this__metricsCache_getMarginSize !== void 0 ? _this__metricsCache_getMarginSize : this._metricsCache.averageMarginSize;
|
|
1081
|
-
var _this__metricsCache_getMarginSize1;
|
|
1082
|
-
var anchorTrailingMargin = (_this__metricsCache_getMarginSize1 = this._metricsCache.getMarginSize(this._anchorIdx + 1)) !== null && _this__metricsCache_getMarginSize1 !== void 0 ? _this__metricsCache_getMarginSize1 : this._metricsCache.averageMarginSize;
|
|
1083
|
-
if (this._anchorIdx === 0) {
|
|
1084
|
-
this._anchorPos = anchorLeadingMargin;
|
|
1085
|
-
}
|
|
1086
|
-
if (this._anchorIdx === this.items.length - 1) {
|
|
1087
|
-
this._anchorPos = this._scrollSize - anchorTrailingMargin - anchorSize;
|
|
1088
|
-
}
|
|
1089
|
-
// Anchor might be outside bounds, so prefer correcting the error and keep
|
|
1090
|
-
// that anchorIdx.
|
|
1091
|
-
var anchorErr = 0;
|
|
1092
|
-
if (this._anchorPos + anchorSize + anchorTrailingMargin < lower) {
|
|
1093
|
-
anchorErr = lower - (this._anchorPos + anchorSize + anchorTrailingMargin);
|
|
1094
|
-
}
|
|
1095
|
-
if (this._anchorPos - anchorLeadingMargin > upper) {
|
|
1096
|
-
anchorErr = upper - (this._anchorPos - anchorLeadingMargin);
|
|
1097
|
-
}
|
|
1098
|
-
if (anchorErr) {
|
|
1099
|
-
this._scrollPosition -= anchorErr;
|
|
1100
|
-
lower -= anchorErr;
|
|
1101
|
-
upper -= anchorErr;
|
|
1102
|
-
this._scrollError += anchorErr;
|
|
1103
|
-
}
|
|
1104
|
-
items.set(this._anchorIdx, {
|
|
1105
|
-
pos: this._anchorPos,
|
|
1106
|
-
size: anchorSize
|
|
1107
|
-
});
|
|
1108
|
-
this._first = this._last = this._anchorIdx;
|
|
1109
|
-
this._physicalMin = this._anchorPos - anchorLeadingMargin;
|
|
1110
|
-
this._physicalMax = this._anchorPos + anchorSize + anchorTrailingMargin;
|
|
1111
|
-
while(this._physicalMin > lower && this._first > 0){
|
|
1112
|
-
var size = this._getSize(--this._first);
|
|
1113
|
-
if (size === undefined) {
|
|
1114
|
-
this._stable = false;
|
|
1115
|
-
size = this._getAverageSize();
|
|
1116
|
-
}
|
|
1117
|
-
var margin = this._metricsCache.getMarginSize(this._first);
|
|
1118
|
-
if (margin === undefined) {
|
|
1119
|
-
this._stable = false;
|
|
1120
|
-
margin = this._metricsCache.averageMarginSize;
|
|
1121
|
-
}
|
|
1122
|
-
this._physicalMin -= size;
|
|
1123
|
-
var pos = this._physicalMin;
|
|
1124
|
-
items.set(this._first, {
|
|
1125
|
-
pos: pos,
|
|
1126
|
-
size: size
|
|
1127
|
-
});
|
|
1128
|
-
this._physicalMin -= margin;
|
|
1129
|
-
if (this._stable === false && this._estimate === false) {
|
|
1130
|
-
break;
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
while(this._physicalMax < upper && this._last < this.items.length - 1){
|
|
1134
|
-
var size1 = this._getSize(++this._last);
|
|
1135
|
-
if (size1 === undefined) {
|
|
1136
|
-
this._stable = false;
|
|
1137
|
-
size1 = this._getAverageSize();
|
|
1138
|
-
}
|
|
1139
|
-
var margin1 = this._metricsCache.getMarginSize(this._last);
|
|
1140
|
-
if (margin1 === undefined) {
|
|
1141
|
-
this._stable = false;
|
|
1142
|
-
margin1 = this._metricsCache.averageMarginSize;
|
|
1143
|
-
}
|
|
1144
|
-
var pos1 = this._physicalMax;
|
|
1145
|
-
items.set(this._last, {
|
|
1146
|
-
pos: pos1,
|
|
1147
|
-
size: size1
|
|
1148
|
-
});
|
|
1149
|
-
this._physicalMax += size1 + margin1;
|
|
1150
|
-
if (!this._stable && !this._estimate) {
|
|
1151
|
-
break;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
// This handles the cases where we were relying on estimated sizes.
|
|
1155
|
-
var extentErr = this._calculateError();
|
|
1156
|
-
if (extentErr) {
|
|
1157
|
-
this._physicalMin -= extentErr;
|
|
1158
|
-
this._physicalMax -= extentErr;
|
|
1159
|
-
this._anchorPos -= extentErr;
|
|
1160
|
-
this._scrollPosition -= extentErr;
|
|
1161
|
-
items.forEach(function(item) {
|
|
1162
|
-
return item.pos -= extentErr;
|
|
1163
|
-
});
|
|
1164
|
-
this._scrollError += extentErr;
|
|
1165
|
-
}
|
|
1166
|
-
if (this._stable) {
|
|
1167
|
-
this._newPhysicalItems = this._physicalItems;
|
|
1168
|
-
this._newPhysicalItems.clear();
|
|
1169
|
-
this._physicalItems = items;
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
},
|
|
1173
|
-
{
|
|
1174
|
-
key: "_calculateError",
|
|
1175
|
-
value: function _calculateError() {
|
|
1176
|
-
if (this._first === 0) {
|
|
1177
|
-
return this._physicalMin;
|
|
1178
|
-
} else if (this._physicalMin <= 0) {
|
|
1179
|
-
return this._physicalMin - this._first * this._delta;
|
|
1180
|
-
} else if (this._last === this.items.length - 1) {
|
|
1181
|
-
return this._physicalMax - this._scrollSize;
|
|
1182
|
-
} else if (this._physicalMax >= this._scrollSize) {
|
|
1183
|
-
return this._physicalMax - this._scrollSize + (this.items.length - 1 - this._last) * this._delta;
|
|
1184
|
-
}
|
|
1185
|
-
return 0;
|
|
1186
|
-
}
|
|
1187
|
-
},
|
|
1188
|
-
{
|
|
1189
|
-
key: "_reflow",
|
|
1190
|
-
value: function _reflow() {
|
|
1191
|
-
var _this = this, _first = _this._first, _last = _this._last;
|
|
1192
|
-
_get(_get_prototype_of(FlowLayout.prototype), "_reflow", this).call(this);
|
|
1193
|
-
if (this._first === -1 && this._last == -1 || this._first === _first && this._last === _last) {
|
|
1194
|
-
this._resetReflowState();
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
},
|
|
1198
|
-
{
|
|
1199
|
-
key: "_resetReflowState",
|
|
1200
|
-
value: function _resetReflowState() {
|
|
1201
|
-
this._anchorIdx = null;
|
|
1202
|
-
this._anchorPos = null;
|
|
1203
|
-
this._stable = true;
|
|
1204
|
-
}
|
|
1205
|
-
},
|
|
1206
|
-
{
|
|
1207
|
-
key: "_updateScrollSize",
|
|
1208
|
-
value: function _updateScrollSize() {
|
|
1209
|
-
var averageMarginSize = this._metricsCache.averageMarginSize;
|
|
1210
|
-
this._scrollSize = Math.max(1, this.items.length * (averageMarginSize + this._getAverageSize()) + averageMarginSize);
|
|
1211
|
-
}
|
|
1212
|
-
},
|
|
1213
|
-
{
|
|
1214
|
-
key: "_delta",
|
|
1215
|
-
get: /**
|
|
1216
|
-
* Returns the average size (precise or estimated) of an item in the scrolling direction,
|
|
1217
|
-
* including any surrounding space.
|
|
1218
|
-
*/ function get() {
|
|
1219
|
-
var averageMarginSize = this._metricsCache.averageMarginSize;
|
|
1220
|
-
return this._getAverageSize() + averageMarginSize;
|
|
1221
|
-
}
|
|
1222
|
-
},
|
|
1223
|
-
{
|
|
1224
|
-
/**
|
|
1225
|
-
* Returns the top and left positioning of the item at idx.
|
|
1226
|
-
*/ key: "_getItemPosition",
|
|
1227
|
-
value: function _getItemPosition(idx) {
|
|
1228
|
-
var _this__metricsCache_getLeadingMarginValue;
|
|
1229
|
-
var _obj;
|
|
1230
|
-
return _obj = {}, _define_property(_obj, this._positionDim, this._getPosition(idx)), _define_property(_obj, this._secondaryPositionDim, 0), _define_property(_obj, offset(this.direction), -((_this__metricsCache_getLeadingMarginValue = this._metricsCache.getLeadingMarginValue(idx, this.direction)) !== null && _this__metricsCache_getLeadingMarginValue !== void 0 ? _this__metricsCache_getLeadingMarginValue : this._metricsCache.averageMarginSize)), _obj;
|
|
1231
|
-
}
|
|
1232
|
-
},
|
|
1233
|
-
{
|
|
1234
|
-
/**
|
|
1235
|
-
* Returns the height and width of the item at idx.
|
|
1236
|
-
*/ key: "_getItemSize",
|
|
1237
|
-
value: function _getItemSize(idx) {
|
|
1238
|
-
var _obj;
|
|
1239
|
-
return _obj = {}, _define_property(_obj, this._sizeDim, this._getSize(idx) || this._getAverageSize()), _define_property(_obj, this._secondarySizeDim, this._itemSize[this._secondarySizeDim]), _obj;
|
|
1240
|
-
}
|
|
1241
|
-
},
|
|
1242
|
-
{
|
|
1243
|
-
key: "_viewDim2Changed",
|
|
1244
|
-
value: function _viewDim2Changed() {
|
|
1245
|
-
this._metricsCache.clear();
|
|
1246
|
-
this._scheduleReflow();
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
]);
|
|
1250
|
-
return FlowLayout;
|
|
1251
|
-
}
|
|
1252
|
-
(BaseLayout);
|
|
1253
|
-
|
|
1254
|
-
export { FlowLayout, flow };
|