@revolist/revogrid 4.23.17 → 4.23.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/revo-grid.cjs.entry.js +5 -2
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +10 -10
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +8 -8
- package/dist/cjs/revogr-data_4.cjs.entry.js +2 -1
- package/dist/cjs/revogr-filter-panel.cjs.entry.js +33 -9
- package/dist/cjs/{throttle-BCwEuJJq.js → throttle-fV6BUmM7.js} +4 -0
- package/dist/collection/components/order/order-row.service.js +8 -8
- package/dist/collection/components/overlay/revogr-overlay-selection.js +9 -9
- package/dist/collection/components/scroll/revogr-viewport-scroll.js +1 -0
- package/dist/collection/plugins/filter/filter.panel.js +33 -9
- package/dist/collection/services/data.provider.js +5 -2
- package/dist/collection/services/local.scroll.timer.js +4 -0
- package/dist/esm/revo-grid.entry.js +5 -2
- package/dist/esm/revogr-attribution_7.entry.js +10 -10
- package/dist/esm/revogr-clipboard_3.entry.js +8 -8
- package/dist/esm/revogr-data_4.entry.js +2 -1
- package/dist/esm/revogr-filter-panel.entry.js +34 -10
- package/dist/esm/{throttle-CaUDyxyU.js → throttle-Cpk1LoGk.js} +4 -0
- package/dist/revo-grid/revo-grid.entry.js +5 -2
- package/dist/revo-grid/revogr-attribution_7.entry.js +10 -10
- package/dist/revo-grid/revogr-clipboard_3.entry.js +8 -8
- package/dist/revo-grid/revogr-data_4.entry.js +2 -1
- package/dist/revo-grid/revogr-filter-panel.entry.js +34 -10
- package/dist/revo-grid/{throttle-CaUDyxyU.js → throttle-Cpk1LoGk.js} +4 -0
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +1 -1
- package/dist/types/plugins/filter/filter.button.d.ts +1 -1
- package/dist/types/plugins/filter/filter.panel.d.ts +3 -0
- package/dist/types/services/local.scroll.timer.d.ts +4 -0
- package/dist/types/types/interfaces.d.ts +4 -0
- package/dist/types/types/selection.d.ts +4 -0
- package/hydrate/index.js +60 -28
- package/hydrate/index.mjs +60 -28
- package/package.json +1 -1
- package/standalone/local.scroll.timer.js +1 -1
- package/standalone/revo-grid.js +1 -1
- package/standalone/revogr-filter-panel.js +1 -1
- package/standalone/revogr-order-editor2.js +1 -1
- package/standalone/revogr-overlay-selection2.js +1 -1
- package/standalone/revogr-viewport-scroll2.js +1 -1
package/hydrate/index.mjs
CHANGED
|
@@ -7503,7 +7503,7 @@ class FilterPanel {
|
|
|
7503
7503
|
return;
|
|
7504
7504
|
}
|
|
7505
7505
|
const path = e.composedPath();
|
|
7506
|
-
const select =
|
|
7506
|
+
const select = this.getAddFilterSelect();
|
|
7507
7507
|
if (select instanceof HTMLSelectElement) {
|
|
7508
7508
|
// click on select should be skipped
|
|
7509
7509
|
if (path.includes(select)) {
|
|
@@ -7517,9 +7517,8 @@ class FilterPanel {
|
|
|
7517
7517
|
}
|
|
7518
7518
|
this.currentFilterId = -1;
|
|
7519
7519
|
const isOutside = !path.includes(this.element);
|
|
7520
|
-
if (
|
|
7521
|
-
|
|
7522
|
-
!isFilterBtn(e.target) &&
|
|
7520
|
+
if (isOutside &&
|
|
7521
|
+
!this.isOwnFilterButton(e.target) &&
|
|
7523
7522
|
this.closeOnOutsideClick) {
|
|
7524
7523
|
this.changes = undefined;
|
|
7525
7524
|
}
|
|
@@ -7643,7 +7642,7 @@ class FilterPanel {
|
|
|
7643
7642
|
this.currentFilterType = el.value;
|
|
7644
7643
|
this.addNewFilterToProp();
|
|
7645
7644
|
// reset value after adding new filter
|
|
7646
|
-
const select =
|
|
7645
|
+
const select = this.getAddFilterSelect();
|
|
7647
7646
|
if (select) {
|
|
7648
7647
|
select.value = defaultType;
|
|
7649
7648
|
this.currentFilterType = defaultType;
|
|
@@ -7847,7 +7846,7 @@ class FilterPanel {
|
|
|
7847
7846
|
}
|
|
7848
7847
|
};
|
|
7849
7848
|
const focusNext = () => {
|
|
7850
|
-
const select =
|
|
7849
|
+
const select = this.getAddFilterSelect();
|
|
7851
7850
|
if (select) {
|
|
7852
7851
|
select.value = defaultType;
|
|
7853
7852
|
this.currentFilterType = defaultType;
|
|
@@ -7881,7 +7880,7 @@ class FilterPanel {
|
|
|
7881
7880
|
}
|
|
7882
7881
|
}, onKeyDown: e => {
|
|
7883
7882
|
if (e.key.toLowerCase() === 'enter') {
|
|
7884
|
-
const select =
|
|
7883
|
+
const select = this.getAddFilterSelect();
|
|
7885
7884
|
if (select) {
|
|
7886
7885
|
focusNext();
|
|
7887
7886
|
}
|
|
@@ -7891,6 +7890,31 @@ class FilterPanel {
|
|
|
7891
7890
|
e.stopPropagation();
|
|
7892
7891
|
} }));
|
|
7893
7892
|
}
|
|
7893
|
+
getAddFilterSelect() {
|
|
7894
|
+
return this.element.querySelector(`#${FILTER_ID}`);
|
|
7895
|
+
}
|
|
7896
|
+
isOwnFilterButton(target) {
|
|
7897
|
+
if (!(target instanceof Element)) {
|
|
7898
|
+
return false;
|
|
7899
|
+
}
|
|
7900
|
+
if (!isFilterBtn(target)) {
|
|
7901
|
+
return false;
|
|
7902
|
+
}
|
|
7903
|
+
const panelGrid = this.getOwningGrid(this.element);
|
|
7904
|
+
const targetGrid = this.getOwningGrid(target);
|
|
7905
|
+
return !!panelGrid && panelGrid === targetGrid;
|
|
7906
|
+
}
|
|
7907
|
+
getOwningGrid(element) {
|
|
7908
|
+
const grid = element.closest('revo-grid');
|
|
7909
|
+
if (grid) {
|
|
7910
|
+
return grid;
|
|
7911
|
+
}
|
|
7912
|
+
const root = element.getRootNode();
|
|
7913
|
+
if (root instanceof ShadowRoot && root.host.localName === 'revo-grid') {
|
|
7914
|
+
return root.host;
|
|
7915
|
+
}
|
|
7916
|
+
return undefined;
|
|
7917
|
+
}
|
|
7894
7918
|
render() {
|
|
7895
7919
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7896
7920
|
const style = {
|
|
@@ -7898,7 +7922,7 @@ class FilterPanel {
|
|
|
7898
7922
|
top: `${(_d = (_c = this.changes) === null || _c === void 0 ? void 0 : _c.y) !== null && _d !== void 0 ? _d : 0}px`,
|
|
7899
7923
|
};
|
|
7900
7924
|
const capts = Object.assign(Object.assign({}, this.filterCaptionsInternal), this.filterCaptions);
|
|
7901
|
-
return (hAsync(Host, { key: '
|
|
7925
|
+
return (hAsync(Host, { key: '2a19b35adb56fb7d23385fffebc768838edee162' }, hAsync("dialog", { key: '94386d7cbc4bd9c631f72928938b1d1550a3de82', class: "filter-panel-dialog", style: style, ref: el => (this.dialog = el), onCancel: e => {
|
|
7902
7926
|
e.preventDefault();
|
|
7903
7927
|
this.onCancel();
|
|
7904
7928
|
} }, this.changes && [
|
|
@@ -7907,7 +7931,7 @@ class FilterPanel {
|
|
|
7907
7931
|
((_g = this.changes) === null || _g === void 0 ? void 0 : _g.hideDefaultFilters) !== true && [
|
|
7908
7932
|
hAsync("label", { key: "filter-title" }, capts.title),
|
|
7909
7933
|
hAsync("div", { key: "filter-holder", class: "filter-holder" }, this.getFilterItemsList()),
|
|
7910
|
-
hAsync("div", { key: "add-filter", class: "add-filter" }, hAsync("select", { key: '
|
|
7934
|
+
hAsync("div", { key: "add-filter", class: "add-filter" }, hAsync("select", { key: '4f7354e39d8e5cf9ae7b735290eff18d105ab87e', id: FILTER_ID, class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))),
|
|
7911
7935
|
],
|
|
7912
7936
|
hAsync("slot", { key: "default-slot" }),
|
|
7913
7937
|
((_j = (_h = this.changes).extraBottomContent) === null || _j === void 0 ? void 0 : _j.call(_h, this.changes)) || '',
|
|
@@ -12653,16 +12677,16 @@ class RowOrderService {
|
|
|
12653
12677
|
return;
|
|
12654
12678
|
}
|
|
12655
12679
|
const newRow = this.getCell(e, data);
|
|
12680
|
+
// rgRow dragged out table
|
|
12681
|
+
if (newRow.y < 0) {
|
|
12682
|
+
newRow.y = 0;
|
|
12683
|
+
}
|
|
12684
|
+
// rgRow dragged to the top
|
|
12685
|
+
else if (newRow.y < this.currentCell.y) {
|
|
12686
|
+
newRow.y++;
|
|
12687
|
+
}
|
|
12656
12688
|
// if position changed
|
|
12657
12689
|
if (newRow.y !== this.currentCell.y) {
|
|
12658
|
-
// rgRow dragged out table
|
|
12659
|
-
if (newRow.y < 0) {
|
|
12660
|
-
newRow.y = 0;
|
|
12661
|
-
}
|
|
12662
|
-
// rgRow dragged to the top
|
|
12663
|
-
else if (newRow.y < this.currentCell.y) {
|
|
12664
|
-
newRow.y++;
|
|
12665
|
-
}
|
|
12666
12690
|
this.config.positionChanged(this.currentCell.y, newRow.y);
|
|
12667
12691
|
}
|
|
12668
12692
|
this.clear();
|
|
@@ -14244,13 +14268,13 @@ class OverlaySelection {
|
|
|
14244
14268
|
/**
|
|
14245
14269
|
* Executes the focus operation on the specified range of cells.
|
|
14246
14270
|
*/
|
|
14247
|
-
doFocus(focus, end, changes) {
|
|
14271
|
+
doFocus(focus, end, changes, originalEvent) {
|
|
14248
14272
|
// 1. Trigger beforeFocus event
|
|
14249
|
-
const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
|
|
14273
|
+
const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
|
|
14250
14274
|
if (defaultPrevented) {
|
|
14251
14275
|
return false;
|
|
14252
14276
|
}
|
|
14253
|
-
const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
|
|
14277
|
+
const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
|
|
14254
14278
|
// 2. Trigger apply focus event
|
|
14255
14279
|
const applyEvent = this.applyFocus.emit(evData);
|
|
14256
14280
|
if (applyEvent.defaultPrevented) {
|
|
@@ -14266,10 +14290,10 @@ class OverlaySelection {
|
|
|
14266
14290
|
y: range.y1,
|
|
14267
14291
|
} }, applyEvent.detail)).defaultPrevented;
|
|
14268
14292
|
}
|
|
14269
|
-
triggerRangeEvent(range) {
|
|
14293
|
+
triggerRangeEvent(range, originalEvent) {
|
|
14270
14294
|
const type = this.types.rowType;
|
|
14271
14295
|
// 1. Apply range
|
|
14272
|
-
const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
|
|
14296
|
+
const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
|
|
14273
14297
|
if (applyEvent.defaultPrevented) {
|
|
14274
14298
|
return false;
|
|
14275
14299
|
}
|
|
@@ -14320,7 +14344,7 @@ class OverlaySelection {
|
|
|
14320
14344
|
return;
|
|
14321
14345
|
}
|
|
14322
14346
|
// Set focus on the current cell
|
|
14323
|
-
this.focus(focusCell, this.range && e.shiftKey);
|
|
14347
|
+
this.focus(focusCell, this.range && e.shiftKey, e);
|
|
14324
14348
|
// Initiate autofill selection
|
|
14325
14349
|
if (this.range) {
|
|
14326
14350
|
targetElement &&
|
|
@@ -14474,7 +14498,7 @@ class OverlaySelection {
|
|
|
14474
14498
|
/**
|
|
14475
14499
|
* Sets the focus on a cell and optionally edits a range.
|
|
14476
14500
|
*/
|
|
14477
|
-
focus(cell, isRangeEdit = false) {
|
|
14501
|
+
focus(cell, isRangeEdit = false, originalEvent) {
|
|
14478
14502
|
if (!cell)
|
|
14479
14503
|
return false;
|
|
14480
14504
|
const end = cell;
|
|
@@ -14482,10 +14506,10 @@ class OverlaySelection {
|
|
|
14482
14506
|
if (isRangeEdit && start) {
|
|
14483
14507
|
const range = getRange(start, end);
|
|
14484
14508
|
if (range) {
|
|
14485
|
-
return this.triggerRangeEvent(range);
|
|
14509
|
+
return this.triggerRangeEvent(range, originalEvent);
|
|
14486
14510
|
}
|
|
14487
14511
|
}
|
|
14488
|
-
return this.doFocus(cell, end);
|
|
14512
|
+
return this.doFocus(cell, end, undefined, originalEvent);
|
|
14489
14513
|
}
|
|
14490
14514
|
get types() {
|
|
14491
14515
|
return {
|
|
@@ -14940,9 +14964,12 @@ class DataProvider {
|
|
|
14940
14964
|
// take out
|
|
14941
14965
|
const toMove = newItemsOrder.splice(newItemsOrder.indexOf(prevItems[from]), // get index in proxy
|
|
14942
14966
|
1);
|
|
14967
|
+
const targetItem = prevItems[from < to ? to + 1 : to];
|
|
14968
|
+
const targetIndex = targetItem === undefined
|
|
14969
|
+
? newItemsOrder.length
|
|
14970
|
+
: newItemsOrder.indexOf(targetItem);
|
|
14943
14971
|
// insert before
|
|
14944
|
-
newItemsOrder.splice(
|
|
14945
|
-
0, ...toMove);
|
|
14972
|
+
newItemsOrder.splice(targetIndex, 0, ...toMove);
|
|
14946
14973
|
storeService.setData({
|
|
14947
14974
|
proxyItems: newItemsOrder,
|
|
14948
14975
|
});
|
|
@@ -21702,6 +21729,10 @@ class LocalScrollTimer {
|
|
|
21702
21729
|
setCoordinate(e) {
|
|
21703
21730
|
this.lastKnownScrollCoordinate[e.dimension] = e.coordinate;
|
|
21704
21731
|
}
|
|
21732
|
+
setCoordinateFromScroll(e) {
|
|
21733
|
+
this.setCoordinate(e);
|
|
21734
|
+
this.mouseWheelScrollTimestamp[e.dimension] = 0;
|
|
21735
|
+
}
|
|
21705
21736
|
/**
|
|
21706
21737
|
* Remember last mw event time
|
|
21707
21738
|
*/
|
|
@@ -22190,6 +22221,7 @@ class RevogrViewportScroll {
|
|
|
22190
22221
|
const lastScrollUpdate = () => {
|
|
22191
22222
|
var _a;
|
|
22192
22223
|
(_a = this.localScrollService) === null || _a === void 0 ? void 0 : _a.scroll(coordinate, type, undefined, undefined, outside);
|
|
22224
|
+
this.localScrollTimer.setCoordinateFromScroll({ dimension: type, coordinate });
|
|
22193
22225
|
};
|
|
22194
22226
|
// apply after throttling
|
|
22195
22227
|
if (this.localScrollTimer.isReady(type, coordinate)) {
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
const t=16e6,i=1e6;let e;function o(o=("undefined"==typeof document?void 0:document)){if("number"==typeof e)return e;const s=null==o?void 0:o.body;if(s){const o=s.ownerDocument,n=o.createElement("div");n.style.cssText=["height:1px","left:-10000px","overflow:scroll","position:absolute","top:-10000px","visibility:hidden","width:1px"].join(";");const r=o.createElement("div");return r.style.height="64000000px",n.appendChild(r),s.appendChild(n),e=Math.max(0,Math.min(n.scrollHeight,64e6)-i),n.remove(),e>i||(e=t),e}return t}function s({contentSize:t,clientSize:e,virtualSize:s=0,maxScrollSize:n=o()}){const r=Math.max(0,n-i),l=Math.max(0,t),a=Math.max(0,e),h=Math.max(0,s||a),c=Math.max(0,l-h),u=Math.max(0,r-a),d=Math.min(c,u),v=c>d&&d>0,S=t=>Math.min(Math.max(0,t||0),c),g=t=>Math.min(Math.max(0,t||0),d),p=t=>c&&d?g(v?S(t)/c*d:t):0;return{contentSize:l,clientSize:a,viewportSize:h,physicalContentSize:a+d,logicalScrollSize:c,physicalScrollSize:d,isCompressed:v,toLogicalCoordinate:t=>c&&d?S(v?g(t)/d*c:t):0,toPhysicalCoordinate:p,getRenderOffset(t){const i=S(t);return i-p(i)}}}const n={contentSize:0,clientSize:0,virtualSize:0,maxSize:0},r=-1;function l(t,i,e=0){return s({contentSize:t,clientSize:i,virtualSize:e}).physicalContentSize}class a{constructor(t){this.cfg=t,this.preventArtificialScroll={rgRow:null,rgCol:null},this.previousScroll={rgRow:r,rgCol:r},this.previousLogicalScroll={rgRow:0,rgCol:0},this.params={rgRow:Object.assign({},n),rgCol:Object.assign({},n)}}setParams(t,i){const e=s(t),o=e.physicalContentSize;this.params[i]=Object.assign(Object.assign({},t),{maxSize:o-t.clientSize,virtualContentSize:o,scrollDimension:e})}async setScroll(t){this.cancelScroll(t.dimension);const i=new Promise(((i,e)=>{if(this.cfg.skipAnimationFrame)return i();const o=window.requestAnimationFrame((()=>{i()}));this.preventArtificialScroll[t.dimension]=e.bind(null,o)}));try{await i;const e=this.getParams(t.dimension);t.coordinate=Math.ceil(t.coordinate),this.previousLogicalScroll[t.dimension]=this.wrapLogicalCoordinate(t.coordinate,e);const o=this.toPhysicalCoordinate(t.coordinate,e);this.previousScroll[t.dimension]=this.wrapPhysicalCoordinate(o,e),this.preventArtificialScroll[t.dimension]=null,this.cfg.applyScroll(Object.assign(Object.assign({},t),{coordinate:o}))}catch(t){window.cancelAnimationFrame(t)}}async setScrollByDelta(t,i){var e;const o=this.getParams(t.dimension),s=this.previousScroll[t.dimension]===r?this.toLogicalCoordinate(i,o):this.previousLogicalScroll[t.dimension],n=this.wrapLogicalCoordinate(s+(null!==(e=t.delta)&&void 0!==e?e:0),o),l=Object.assign(Object.assign({},t),{coordinate:n});return await this.setScroll(l),l}scroll(t,i,e=!1,o,s=!1){if(this.cancelScroll(i),!e&&this.previousScroll[i]===t)return void(this.previousScroll[i]=r);const n=this.getParams(i),l=this.toLogicalScrollCoordinate(t,i,n,o);this.cfg.runScroll({dimension:i,coordinate:l,delta:o,outside:s}),this.previousLogicalScroll[i]=l}getParams(t){return this.params[t]}wrapPhysicalCoordinate(t,i){return t<0?r:"number"==typeof i.maxSize&&t>i.maxSize?i.maxSize:t}wrapLogicalCoordinate(t,i){var e,o;return t<0?0:Math.min(t,null!==(o=null===(e=i.scrollDimension)||void 0===e?void 0:e.logicalScrollSize)&&void 0!==o?o:t)}cancelScroll(t){var i,e;null===(e=(i=this.preventArtificialScroll)[t])||void 0===e||e.call(i),this.preventArtificialScroll[t]=null}toLogicalScrollCoordinate(t,i,e,o){const s=e.scrollDimension;if(!s)return t;if("number"==typeof o&&s.isCompressed){const e=this.previousScroll[i]===r?s.toLogicalCoordinate(t-o):this.previousLogicalScroll[i];return s.toLogicalCoordinate(s.toPhysicalCoordinate(e+o))}return s.toLogicalCoordinate(t)}toPhysicalCoordinate(t,i){var e,o;return null!==(o=null===(e=i.scrollDimension)||void 0===e?void 0:e.toPhysicalCoordinate(t))&&void 0!==o?o:t}toLogicalCoordinate(t,i){var e,o;return null!==(o=null===(e=i.scrollDimension)||void 0===e?void 0:e.toLogicalCoordinate(t))&&void 0!==o?o:t}}class h{constructor(t=10){this.scrollThrottling=t,this.mouseWheelScrollTimestamp={rgCol:0,rgRow:0},this.lastKnownScrollCoordinate={rgCol:0,rgRow:0},this.lastScrollUpdateCallbacks={}}setCoordinate(t){this.lastKnownScrollCoordinate[t.dimension]=t.coordinate}latestScrollUpdate(t){this.mouseWheelScrollTimestamp[t]=(new Date).getTime()}isReady(t,i){return this.lastScrollUpdateCallbacks[t]&&this.clearLastScrollUpdate(t),this.verifyChange(t,i)}verifyChange(t,i){return(new Date).getTime()-this.mouseWheelScrollTimestamp[t]>this.scrollThrottling&&i!==this.lastKnownScrollCoordinate[t]}clearLastScrollUpdate(t){var i,e;clearTimeout(null!==(e=null===(i=this.lastScrollUpdateCallbacks[t])||void 0===i?void 0:i.timeout)&&void 0!==e?e:0),delete this.lastScrollUpdateCallbacks[t]}throttleLastScrollUpdate(t,i,e){if(this.scrollThrottling){this.clearLastScrollUpdate(t);const o=this.lastScrollUpdateCallbacks[t]={callback:e,timestamp:(new Date).getTime(),coordinate:i,timeout:0};o.timeout=setTimeout((()=>{this.clearLastScrollUpdate(t),this.mouseWheelScrollTimestamp[t]<o.timestamp&&this.verifyChange(t,o.coordinate)&&o.callback()}),this.scrollThrottling+50)}}}export{h as L,a,l as b,s as g}
|
|
4
|
+
const t=16e6,i=1e6;let e;function o(o=("undefined"==typeof document?void 0:document)){if("number"==typeof e)return e;const s=null==o?void 0:o.body;if(s){const o=s.ownerDocument,n=o.createElement("div");n.style.cssText=["height:1px","left:-10000px","overflow:scroll","position:absolute","top:-10000px","visibility:hidden","width:1px"].join(";");const r=o.createElement("div");return r.style.height="64000000px",n.appendChild(r),s.appendChild(n),e=Math.max(0,Math.min(n.scrollHeight,64e6)-i),n.remove(),e>i||(e=t),e}return t}function s({contentSize:t,clientSize:e,virtualSize:s=0,maxScrollSize:n=o()}){const r=Math.max(0,n-i),l=Math.max(0,t),a=Math.max(0,e),h=Math.max(0,s||a),c=Math.max(0,l-h),u=Math.max(0,r-a),d=Math.min(c,u),v=c>d&&d>0,S=t=>Math.min(Math.max(0,t||0),c),g=t=>Math.min(Math.max(0,t||0),d),p=t=>c&&d?g(v?S(t)/c*d:t):0;return{contentSize:l,clientSize:a,viewportSize:h,physicalContentSize:a+d,logicalScrollSize:c,physicalScrollSize:d,isCompressed:v,toLogicalCoordinate:t=>c&&d?S(v?g(t)/d*c:t):0,toPhysicalCoordinate:p,getRenderOffset(t){const i=S(t);return i-p(i)}}}const n={contentSize:0,clientSize:0,virtualSize:0,maxSize:0},r=-1;function l(t,i,e=0){return s({contentSize:t,clientSize:i,virtualSize:e}).physicalContentSize}class a{constructor(t){this.cfg=t,this.preventArtificialScroll={rgRow:null,rgCol:null},this.previousScroll={rgRow:r,rgCol:r},this.previousLogicalScroll={rgRow:0,rgCol:0},this.params={rgRow:Object.assign({},n),rgCol:Object.assign({},n)}}setParams(t,i){const e=s(t),o=e.physicalContentSize;this.params[i]=Object.assign(Object.assign({},t),{maxSize:o-t.clientSize,virtualContentSize:o,scrollDimension:e})}async setScroll(t){this.cancelScroll(t.dimension);const i=new Promise(((i,e)=>{if(this.cfg.skipAnimationFrame)return i();const o=window.requestAnimationFrame((()=>{i()}));this.preventArtificialScroll[t.dimension]=e.bind(null,o)}));try{await i;const e=this.getParams(t.dimension);t.coordinate=Math.ceil(t.coordinate),this.previousLogicalScroll[t.dimension]=this.wrapLogicalCoordinate(t.coordinate,e);const o=this.toPhysicalCoordinate(t.coordinate,e);this.previousScroll[t.dimension]=this.wrapPhysicalCoordinate(o,e),this.preventArtificialScroll[t.dimension]=null,this.cfg.applyScroll(Object.assign(Object.assign({},t),{coordinate:o}))}catch(t){window.cancelAnimationFrame(t)}}async setScrollByDelta(t,i){var e;const o=this.getParams(t.dimension),s=this.previousScroll[t.dimension]===r?this.toLogicalCoordinate(i,o):this.previousLogicalScroll[t.dimension],n=this.wrapLogicalCoordinate(s+(null!==(e=t.delta)&&void 0!==e?e:0),o),l=Object.assign(Object.assign({},t),{coordinate:n});return await this.setScroll(l),l}scroll(t,i,e=!1,o,s=!1){if(this.cancelScroll(i),!e&&this.previousScroll[i]===t)return void(this.previousScroll[i]=r);const n=this.getParams(i),l=this.toLogicalScrollCoordinate(t,i,n,o);this.cfg.runScroll({dimension:i,coordinate:l,delta:o,outside:s}),this.previousLogicalScroll[i]=l}getParams(t){return this.params[t]}wrapPhysicalCoordinate(t,i){return t<0?r:"number"==typeof i.maxSize&&t>i.maxSize?i.maxSize:t}wrapLogicalCoordinate(t,i){var e,o;return t<0?0:Math.min(t,null!==(o=null===(e=i.scrollDimension)||void 0===e?void 0:e.logicalScrollSize)&&void 0!==o?o:t)}cancelScroll(t){var i,e;null===(e=(i=this.preventArtificialScroll)[t])||void 0===e||e.call(i),this.preventArtificialScroll[t]=null}toLogicalScrollCoordinate(t,i,e,o){const s=e.scrollDimension;if(!s)return t;if("number"==typeof o&&s.isCompressed){const e=this.previousScroll[i]===r?s.toLogicalCoordinate(t-o):this.previousLogicalScroll[i];return s.toLogicalCoordinate(s.toPhysicalCoordinate(e+o))}return s.toLogicalCoordinate(t)}toPhysicalCoordinate(t,i){var e,o;return null!==(o=null===(e=i.scrollDimension)||void 0===e?void 0:e.toPhysicalCoordinate(t))&&void 0!==o?o:t}toLogicalCoordinate(t,i){var e,o;return null!==(o=null===(e=i.scrollDimension)||void 0===e?void 0:e.toLogicalCoordinate(t))&&void 0!==o?o:t}}class h{constructor(t=10){this.scrollThrottling=t,this.mouseWheelScrollTimestamp={rgCol:0,rgRow:0},this.lastKnownScrollCoordinate={rgCol:0,rgRow:0},this.lastScrollUpdateCallbacks={}}setCoordinate(t){this.lastKnownScrollCoordinate[t.dimension]=t.coordinate}setCoordinateFromScroll(t){this.setCoordinate(t),this.mouseWheelScrollTimestamp[t.dimension]=0}latestScrollUpdate(t){this.mouseWheelScrollTimestamp[t]=(new Date).getTime()}isReady(t,i){return this.lastScrollUpdateCallbacks[t]&&this.clearLastScrollUpdate(t),this.verifyChange(t,i)}verifyChange(t,i){return(new Date).getTime()-this.mouseWheelScrollTimestamp[t]>this.scrollThrottling&&i!==this.lastKnownScrollCoordinate[t]}clearLastScrollUpdate(t){var i,e;clearTimeout(null!==(e=null===(i=this.lastScrollUpdateCallbacks[t])||void 0===i?void 0:i.timeout)&&void 0!==e?e:0),delete this.lastScrollUpdateCallbacks[t]}throttleLastScrollUpdate(t,i,e){if(this.scrollThrottling){this.clearLastScrollUpdate(t);const o=this.lastScrollUpdateCallbacks[t]={callback:e,timestamp:(new Date).getTime(),coordinate:i,timeout:0};o.timeout=setTimeout((()=>{this.clearLastScrollUpdate(t),this.mouseWheelScrollTimestamp[t]<o.timestamp&&this.verifyChange(t,o.coordinate)&&o.callback()}),this.scrollThrottling+50)}}}export{h as L,a,l as b,s as g}
|