@revolist/revogrid 4.12.12 → 4.13.2

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.
Files changed (95) hide show
  1. package/dist/cjs/{column.drag.plugin-0ce0b39a.js → column.drag.plugin-0f367fe1.js} +2 -1
  2. package/dist/cjs/column.drag.plugin-0f367fe1.js.map +1 -0
  3. package/dist/cjs/column.service-b59380a3.js.map +1 -1
  4. package/dist/cjs/{sorting.sign-a1e9d97a.js → grouping.row.renderer-d6119ced.js} +6 -6
  5. package/dist/cjs/grouping.row.renderer-d6119ced.js.map +1 -0
  6. package/dist/cjs/index.cjs.js +7 -6
  7. package/dist/cjs/index.cjs.js.map +1 -1
  8. package/dist/cjs/revo-grid.cjs.entry.js +2 -2
  9. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  10. package/dist/cjs/revogr-data_4.cjs.entry.js +5 -5
  11. package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
  12. package/dist/cjs/revogr-filter-panel.cjs.entry.js +1 -1
  13. package/dist/cjs/revogr-filter-panel.cjs.entry.js.map +1 -1
  14. package/dist/collection/components/revoGrid/revo-grid-style.css +109 -197
  15. package/dist/collection/plugins/filter/filter.style.css +12 -25
  16. package/dist/collection/plugins/sorting/sorting.plugin.js +2 -0
  17. package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
  18. package/dist/collection/store/selection/selection.store.js.map +1 -1
  19. package/dist/esm/{column.drag.plugin-017c4fb3.js → column.drag.plugin-d201beb7.js} +2 -2
  20. package/dist/esm/{column.drag.plugin-017c4fb3.js.map → column.drag.plugin-d201beb7.js.map} +1 -1
  21. package/dist/esm/column.service-f39c0a1d.js.map +1 -1
  22. package/dist/esm/{sorting.sign-c02e3b12.js → grouping.row.renderer-95f32c6b.js} +6 -6
  23. package/dist/esm/grouping.row.renderer-95f32c6b.js.map +1 -0
  24. package/dist/esm/index.js +3 -3
  25. package/dist/esm/revo-grid.entry.js +2 -2
  26. package/dist/esm/revo-grid.entry.js.map +1 -1
  27. package/dist/esm/revogr-data_4.entry.js +1 -1
  28. package/dist/esm/revogr-filter-panel.entry.js +1 -1
  29. package/dist/esm/revogr-filter-panel.entry.js.map +1 -1
  30. package/dist/revo-grid/app-globals-6b929fd8.js +8 -1
  31. package/dist/revo-grid/app-globals-6b929fd8.js.map +1 -1
  32. package/dist/revo-grid/column.drag.plugin-d201beb7.js +2522 -0
  33. package/dist/revo-grid/column.drag.plugin-d201beb7.js.map +1 -0
  34. package/dist/revo-grid/column.service-f39c0a1d.js +1293 -1
  35. package/dist/revo-grid/column.service-f39c0a1d.js.map +1 -1
  36. package/dist/revo-grid/debounce-b3166f78.js +491 -1
  37. package/dist/revo-grid/debounce-b3166f78.js.map +1 -1
  38. package/dist/revo-grid/dimension.helpers-5567e424.js +3608 -1
  39. package/dist/revo-grid/dimension.helpers-5567e424.js.map +1 -1
  40. package/dist/revo-grid/edit.utils-b59306be.js +13 -1
  41. package/dist/revo-grid/edit.utils-b59306be.js.map +1 -1
  42. package/dist/revo-grid/events-cf0893a3.js +38 -1
  43. package/dist/revo-grid/events-cf0893a3.js.map +1 -1
  44. package/dist/revo-grid/filter.button-84396156.js +34 -1
  45. package/dist/revo-grid/filter.button-84396156.js.map +1 -1
  46. package/dist/revo-grid/grouping.row.renderer-95f32c6b.js +65 -0
  47. package/dist/revo-grid/grouping.row.renderer-95f32c6b.js.map +1 -0
  48. package/dist/revo-grid/header-cell-renderer-31f53644.js +335 -1
  49. package/dist/revo-grid/header-cell-renderer-31f53644.js.map +1 -1
  50. package/dist/revo-grid/index-f6fae858.js +2090 -2
  51. package/dist/revo-grid/index-f6fae858.js.map +1 -1
  52. package/dist/revo-grid/index.esm.js +160 -1
  53. package/dist/revo-grid/index.esm.js.map +1 -1
  54. package/dist/revo-grid/key.utils-3632161b.js +85 -1
  55. package/dist/revo-grid/key.utils-3632161b.js.map +1 -1
  56. package/dist/revo-grid/resize-observer-83c9e167.js +501 -1
  57. package/dist/revo-grid/resize-observer-83c9e167.js.map +1 -1
  58. package/dist/revo-grid/revo-grid.entry.js +1943 -1
  59. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  60. package/dist/revo-grid/revo-grid.esm.js +21 -1
  61. package/dist/revo-grid/revo-grid.esm.js.map +1 -1
  62. package/dist/revo-grid/revogr-attribution_7.entry.js +1446 -1
  63. package/dist/revo-grid/revogr-attribution_7.entry.js.map +1 -1
  64. package/dist/revo-grid/revogr-clipboard_3.entry.js +455 -1
  65. package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
  66. package/dist/revo-grid/revogr-data_4.entry.js +960 -1
  67. package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
  68. package/dist/revo-grid/revogr-filter-panel.entry.js +340 -1
  69. package/dist/revo-grid/revogr-filter-panel.entry.js.map +1 -1
  70. package/dist/revo-grid/text-editor-e47e56c3.js +74 -1
  71. package/dist/revo-grid/text-editor-e47e56c3.js.map +1 -1
  72. package/dist/revo-grid/throttle-dec28f5b.js +229 -1
  73. package/dist/revo-grid/throttle-dec28f5b.js.map +1 -1
  74. package/dist/revo-grid/viewport.helpers-7e7f9dad.js +48 -1
  75. package/dist/revo-grid/viewport.helpers-7e7f9dad.js.map +1 -1
  76. package/dist/revo-grid/viewport.store-c18a25a6.js +402 -1
  77. package/dist/revo-grid/viewport.store-c18a25a6.js.map +1 -1
  78. package/dist/types/plugins/sorting/sorting.plugin.d.ts +2 -0
  79. package/dist/types/store/selection/selection.store.d.ts +1 -1
  80. package/hydrate/index.js +7 -7
  81. package/hydrate/index.mjs +7 -7
  82. package/package.json +1 -1
  83. package/standalone/column.service.js.map +1 -1
  84. package/standalone/index.js +1 -1
  85. package/standalone/revo-grid.js +2 -2
  86. package/standalone/revo-grid.js.map +1 -1
  87. package/standalone/revogr-filter-panel.js +1 -1
  88. package/standalone/revogr-filter-panel.js.map +1 -1
  89. package/dist/cjs/column.drag.plugin-0ce0b39a.js.map +0 -1
  90. package/dist/cjs/sorting.sign-a1e9d97a.js.map +0 -1
  91. package/dist/esm/sorting.sign-c02e3b12.js.map +0 -1
  92. package/dist/revo-grid/column.drag.plugin-017c4fb3.js +0 -5
  93. package/dist/revo-grid/column.drag.plugin-017c4fb3.js.map +0 -1
  94. package/dist/revo-grid/sorting.sign-c02e3b12.js +0 -5
  95. package/dist/revo-grid/sorting.sign-c02e3b12.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["TextEditor","constructor","data","saveCallback","this","editInput","element","editCell","undefined","componentDidRender","timeout","_a","focus","onKeyDown","e","isEnter","isEnterKeyValue","key","isKeyTab","isTab","target","isComposing","beforeDisconnect","getValue","blur","value","render","h","_additionalData","type","enterKeyHint","_b","val","ref","el"],"sources":["src/components/editors/text-editor.ts"],"sourcesContent":["import { type VNode, h as createElement } from '@stencil/core';\nimport { isEnterKeyValue, isTab } from '../../utils/key.utils';\nimport { timeout } from '../../utils';\nimport type { EditCell, EditorBase, ColumnDataSchemaModel } from '@type';\n\n/**\n * Represents a cell editor in a grid.\n *\n * It's a good place to start with your own editor.\n * It manages the editing of cells by handling events, saving data, rendering the editor UI, and managing the lifecycle of the editor instance.\n */\n\n/**\n * Callback triggered on cell editor save\n * Closes editor when called\n * @param preventFocus - if true editor will not be closed and next cell will not be focused\n */\nexport type SaveCallback = (value: any, preventFocus: boolean) => void;\n\nexport class TextEditor implements EditorBase {\n editInput: HTMLInputElement | null = null;\n\n element: Element | null = null;\n editCell?: EditCell = undefined;\n\n constructor(\n public data: ColumnDataSchemaModel,\n private saveCallback?: SaveCallback,\n ) {}\n\n /**\n * Callback triggered on cell editor render\n */\n async componentDidRender(): Promise<void> {\n if (this.editInput) {\n await timeout();\n this.editInput?.focus();\n }\n }\n\n onKeyDown(e: KeyboardEvent) {\n const isEnter = isEnterKeyValue(e.key);\n const isKeyTab = isTab(e.key);\n\n if (\n (isKeyTab || isEnter) &&\n e.target &&\n this.saveCallback &&\n !e.isComposing\n ) {\n // blur is needed to avoid autoscroll\n this.beforeDisconnect();\n // request callback which will close cell after all\n this.saveCallback(this.getValue(), isKeyTab);\n }\n }\n\n /**\n * IMPORTANT: Prevent scroll glitches when editor is closed and focus is on current input element.\n */\n beforeDisconnect() {\n this.editInput?.blur();\n }\n\n /**\n * Get value from input\n */\n getValue() {\n return this.editInput?.value;\n }\n\n /**\n * Render method for Editor plugin.\n * Renders input element with passed data from cell.\n * @param {Function} h - h function from stencil render.\n * @param {Object} _additionalData - additional data from plugin.\n * @returns {VNode} - input element.\n */\n render(h: typeof createElement, _additionalData: any): VNode | VNode[] {\n return h('input', {\n type: 'text',\n enterKeyHint: 'enter',\n // set input value from cell data\n value: this.editCell?.val ?? '',\n // save input element as ref for further usage\n ref: (el: HTMLInputElement | null) => {\n this.editInput = el;\n },\n // listen to keydown event on input element\n onKeyDown: (e: KeyboardEvent) => this.onKeyDown(e),\n });\n }\n}\n"],"mappings":";;;6GAmBaA,EAMX,WAAAC,CACSC,EACCC,GADDC,KAAAF,OACCE,KAAAD,eAPVC,KAAAC,UAAqC,KAErCD,KAAAE,QAA0B,KAC1BF,KAAAG,SAAsBC,S,CAUtB,wBAAMC,G,MACJ,GAAIL,KAAKC,UAAW,OACZK,KACNC,EAAAP,KAAKC,aAAS,MAAAM,SAAA,SAAAA,EAAEC,O,EAIpB,SAAAC,CAAUC,GACR,MAAMC,EAAUC,EAAgBF,EAAEG,KAClC,MAAMC,EAAWC,EAAML,EAAEG,KAEzB,IACGC,GAAYH,IACbD,EAAEM,QACFhB,KAAKD,eACJW,EAAEO,YACH,CAEAjB,KAAKkB,mBAELlB,KAAKD,aAAaC,KAAKmB,WAAYL,E,EAOvC,gBAAAI,G,OACEX,EAAAP,KAAKC,aAAS,MAAAM,SAAA,SAAAA,EAAEa,M,CAMlB,QAAAD,G,MACE,OAAOZ,EAAAP,KAAKC,aAAS,MAAAM,SAAA,SAAAA,EAAEc,K,CAUzB,MAAAC,CAAOC,EAAyBC,G,QAC9B,OAAOD,EAAE,QAAS,CAChB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AAC,CAAuB,EAAE,eAAoB;;QAClD,OAAO,CAAC,CAAC,OAAO,EAAE;YAChB,IAAI,EAAE,MAAM;YACZ,YAAY,EAAE,OAAO;;YAErB,KAAK,EAAE,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,GAAG,mCAAI,EAAE;;YAE/B,GAAG,EAAE,CAAC,EAA2B;gBAC/B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;aACrB;;YAED,SAAS,EAAE,CAAC,CAAgB,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;SACnD,CAAC,CAAC;KACJ;;;;;","names":[],"sources":["src/components/editors/text-editor.ts"],"sourcesContent":["import { type VNode, h as createElement } from '@stencil/core';\nimport { isEnterKeyValue, isTab } from '../../utils/key.utils';\nimport { timeout } from '../../utils';\nimport type { EditCell, EditorBase, ColumnDataSchemaModel } from '@type';\n\n/**\n * Represents a cell editor in a grid.\n *\n * It's a good place to start with your own editor.\n * It manages the editing of cells by handling events, saving data, rendering the editor UI, and managing the lifecycle of the editor instance.\n */\n\n/**\n * Callback triggered on cell editor save\n * Closes editor when called\n * @param preventFocus - if true editor will not be closed and next cell will not be focused\n */\nexport type SaveCallback = (value: any, preventFocus: boolean) => void;\n\nexport class TextEditor implements EditorBase {\n editInput: HTMLInputElement | null = null;\n\n element: Element | null = null;\n editCell?: EditCell = undefined;\n\n constructor(\n public data: ColumnDataSchemaModel,\n private saveCallback?: SaveCallback,\n ) {}\n\n /**\n * Callback triggered on cell editor render\n */\n async componentDidRender(): Promise<void> {\n if (this.editInput) {\n await timeout();\n this.editInput?.focus();\n }\n }\n\n onKeyDown(e: KeyboardEvent) {\n const isEnter = isEnterKeyValue(e.key);\n const isKeyTab = isTab(e.key);\n\n if (\n (isKeyTab || isEnter) &&\n e.target &&\n this.saveCallback &&\n !e.isComposing\n ) {\n // blur is needed to avoid autoscroll\n this.beforeDisconnect();\n // request callback which will close cell after all\n this.saveCallback(this.getValue(), isKeyTab);\n }\n }\n\n /**\n * IMPORTANT: Prevent scroll glitches when editor is closed and focus is on current input element.\n */\n beforeDisconnect() {\n this.editInput?.blur();\n }\n\n /**\n * Get value from input\n */\n getValue() {\n return this.editInput?.value;\n }\n\n /**\n * Render method for Editor plugin.\n * Renders input element with passed data from cell.\n * @param {Function} h - h function from stencil render.\n * @param {Object} _additionalData - additional data from plugin.\n * @returns {VNode} - input element.\n */\n render(h: typeof createElement, _additionalData: any): VNode | VNode[] {\n return h('input', {\n type: 'text',\n enterKeyHint: 'enter',\n // set input value from cell data\n value: this.editCell?.val ?? '',\n // save input element as ref for further usage\n ref: (el: HTMLInputElement | null) => {\n this.editInput = el;\n },\n // listen to keydown event on input element\n onKeyDown: (e: KeyboardEvent) => this.onKeyDown(e),\n });\n }\n}\n"],"version":3}
@@ -1,5 +1,233 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import{q as t}from"./dimension.helpers-5567e424.js";import{d as i,a as r}from"./debounce-b3166f78.js";const s={contentSize:0,clientSize:0,virtualSize:0,maxSize:0};const e=-1;function n(t,i,r=0){if(r>t){return 0}return t+(r?i-r:0)}class o{constructor(t){this.cfg=t;this.preventArtificialScroll={rgRow:null,rgCol:null};this.previousScroll={rgRow:e,rgCol:e};this.params={rgRow:Object.assign({},s),rgCol:Object.assign({},s)}}setParams(t,i){const r=n(t.contentSize,t.clientSize,t.virtualSize);this.params[i]=Object.assign(Object.assign({},t),{maxSize:r-t.clientSize,virtualContentSize:r})}async setScroll(t){this.cancelScroll(t.dimension);const i=new Promise(((i,r)=>{if(this.cfg.skipAnimationFrame){return i()}const s=window.requestAnimationFrame((()=>{i()}));this.preventArtificialScroll[t.dimension]=r.bind(null,s)}));try{await i;const r=this.getParams(t.dimension);t.coordinate=Math.ceil(t.coordinate);this.previousScroll[t.dimension]=this.wrapCoordinate(t.coordinate,r);this.preventArtificialScroll[t.dimension]=null;this.cfg.applyScroll(Object.assign(Object.assign({},t),{coordinate:r.virtualSize?this.convert(t.coordinate,r,false):t.coordinate}))}catch(t){window.cancelAnimationFrame(t)}}scroll(t,i,r=false,s,n=false){this.cancelScroll(i);if(!r&&this.previousScroll[i]===t){this.previousScroll[i]=e;return}const o=this.getParams(i);this.cfg.runScroll({dimension:i,coordinate:o.virtualSize?this.convert(t,o):t,delta:s,outside:n})}getParams(t){return this.params[t]}wrapCoordinate(t,i){if(t<0){return e}if(typeof i.maxSize==="number"&&t>i.maxSize){return i.maxSize}return t}cancelScroll(t){var i,r;(r=(i=this.preventArtificialScroll)[t])===null||r===void 0?void 0:r.call(i);this.preventArtificialScroll[t]=null}convert(i,r,s=true){var e;const n=r.clientSize;const o=[0,((e=r.virtualContentSize)!==null&&e!==void 0?e:n)-n];const a=[0,r.contentSize-r.virtualSize];if(s){return t(i,o,a)}return t(i,a,o)}}class a{constructor(t=10){this.scrollThrottling=t;this.mouseWheelScrollTimestamp={rgCol:0,rgRow:0};this.lastKnownScrollCoordinate={rgCol:0,rgRow:0}}setCoordinate(t){this.lastKnownScrollCoordinate[t.dimension]=t.coordinate}latestScrollUpdate(t){this.mouseWheelScrollTimestamp[t]=(new Date).getTime()}isReady(t,i){const r=(new Date).getTime()-this.mouseWheelScrollTimestamp[t];return r>this.scrollThrottling&&i!==this.lastKnownScrollCoordinate[t]}}var c="Expected a function";function l(t,s,e){var n=true,o=true;if(typeof t!="function"){throw new TypeError(c)}if(r(e)){n="leading"in e?!!e.leading:n;o="trailing"in e?!!e.trailing:o}return i(t,s,{leading:n,maxWait:s,trailing:o})}export{a as L,o as a,n as g,l as t};
4
+ import { q as scaleValue } from './dimension.helpers-5567e424.js';
5
+ import { d as debounce, a as isObject } from './debounce-b3166f78.js';
6
+
7
+ const initialParams = {
8
+ contentSize: 0,
9
+ clientSize: 0,
10
+ virtualSize: 0,
11
+ maxSize: 0,
12
+ };
13
+ const NO_COORDINATE = -1;
14
+ /**
15
+ * Based on content size, client size and virtual size
16
+ * return full size
17
+ */
18
+ function getContentSize(contentSize, clientSize, virtualSize = 0) {
19
+ if (virtualSize > contentSize) {
20
+ return 0;
21
+ }
22
+ return contentSize + (virtualSize ? clientSize - virtualSize : 0);
23
+ }
24
+ class LocalScrollService {
25
+ constructor(cfg) {
26
+ this.cfg = cfg;
27
+ this.preventArtificialScroll = {
28
+ rgRow: null,
29
+ rgCol: null,
30
+ };
31
+ // to check if scroll changed
32
+ this.previousScroll = {
33
+ rgRow: NO_COORDINATE,
34
+ rgCol: NO_COORDINATE,
35
+ };
36
+ this.params = {
37
+ rgRow: Object.assign({}, initialParams),
38
+ rgCol: Object.assign({}, initialParams),
39
+ };
40
+ }
41
+ setParams(params, dimension) {
42
+ const virtualContentSize = getContentSize(params.contentSize, params.clientSize, params.virtualSize);
43
+ this.params[dimension] = Object.assign(Object.assign({}, params), { maxSize: virtualContentSize - params.clientSize, virtualContentSize });
44
+ }
45
+ // apply scroll values after scroll done
46
+ async setScroll(e) {
47
+ this.cancelScroll(e.dimension);
48
+ // start frame animation
49
+ const frameAnimation = new Promise((resolve, reject) => {
50
+ // for example safari desktop has issues with animation frame
51
+ if (this.cfg.skipAnimationFrame) {
52
+ return resolve();
53
+ }
54
+ const animationId = window.requestAnimationFrame(() => {
55
+ resolve();
56
+ });
57
+ this.preventArtificialScroll[e.dimension] = reject.bind(null, animationId);
58
+ });
59
+ try {
60
+ await frameAnimation;
61
+ const params = this.getParams(e.dimension);
62
+ e.coordinate = Math.ceil(e.coordinate);
63
+ this.previousScroll[e.dimension] = this.wrapCoordinate(e.coordinate, params);
64
+ this.preventArtificialScroll[e.dimension] = null;
65
+ this.cfg.applyScroll(Object.assign(Object.assign({}, e), { coordinate: params.virtualSize
66
+ ? this.convert(e.coordinate, params, false)
67
+ : e.coordinate }));
68
+ }
69
+ catch (id) {
70
+ window.cancelAnimationFrame(id);
71
+ }
72
+ }
73
+ /**
74
+ * On scroll event started
75
+ */
76
+ scroll(coordinate, dimension, force = false, delta, outside = false) {
77
+ // cancel all previous scrolls for same dimension
78
+ this.cancelScroll(dimension);
79
+ // drop if no change
80
+ if (!force && this.previousScroll[dimension] === coordinate) {
81
+ this.previousScroll[dimension] = NO_COORDINATE;
82
+ return;
83
+ }
84
+ const param = this.getParams(dimension);
85
+ // let component know about scroll event started
86
+ this.cfg.runScroll({
87
+ dimension: dimension,
88
+ coordinate: param.virtualSize
89
+ ? this.convert(coordinate, param)
90
+ : coordinate,
91
+ delta,
92
+ outside,
93
+ });
94
+ }
95
+ getParams(dimension) {
96
+ return this.params[dimension];
97
+ }
98
+ // check if scroll outside of region to avoid looping
99
+ wrapCoordinate(c, param) {
100
+ if (c < 0) {
101
+ return NO_COORDINATE;
102
+ }
103
+ if (typeof param.maxSize === 'number' && c > param.maxSize) {
104
+ return param.maxSize;
105
+ }
106
+ return c;
107
+ }
108
+ // prevent already started scroll, performance optimization
109
+ cancelScroll(dimension) {
110
+ var _a, _b;
111
+ (_b = (_a = this.preventArtificialScroll)[dimension]) === null || _b === void 0 ? void 0 : _b.call(_a);
112
+ this.preventArtificialScroll[dimension] = null;
113
+ }
114
+ /* convert virtual to real and back, scale range */
115
+ convert(pos, param, toReal = true) {
116
+ var _a;
117
+ const minRange = param.clientSize;
118
+ const from = [0, ((_a = param.virtualContentSize) !== null && _a !== void 0 ? _a : minRange) - minRange];
119
+ const to = [0, param.contentSize - param.virtualSize];
120
+ if (toReal) {
121
+ return scaleValue(pos, from, to);
122
+ }
123
+ return scaleValue(pos, to, from);
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Apply changes only if mousewheel event happened some time ago (scrollThrottling)
129
+ */
130
+ class LocalScrollTimer {
131
+ constructor(scrollThrottling = 10) {
132
+ this.scrollThrottling = scrollThrottling;
133
+ /**
134
+ * Last mw event time for trigger scroll function below
135
+ * If mousewheel function was ignored we still need to trigger render
136
+ */
137
+ this.mouseWheelScrollTimestamp = {
138
+ rgCol: 0,
139
+ rgRow: 0,
140
+ };
141
+ this.lastKnownScrollCoordinate = {
142
+ rgCol: 0,
143
+ rgRow: 0,
144
+ };
145
+ }
146
+ setCoordinate(e) {
147
+ this.lastKnownScrollCoordinate[e.dimension] = e.coordinate;
148
+ }
149
+ /**
150
+ * Remember last mw event time
151
+ */
152
+ latestScrollUpdate(dimension) {
153
+ this.mouseWheelScrollTimestamp[dimension] = new Date().getTime();
154
+ }
155
+ /**
156
+ * Check if scroll is ready to accept new value
157
+ */
158
+ isReady(type, coordinate) {
159
+ const change = new Date().getTime() - this.mouseWheelScrollTimestamp[type];
160
+ // apply after throttling
161
+ return (change > this.scrollThrottling &&
162
+ coordinate !== this.lastKnownScrollCoordinate[type]);
163
+ }
164
+ }
165
+
166
+ /** Error message constants. */
167
+ var FUNC_ERROR_TEXT = 'Expected a function';
168
+
169
+ /**
170
+ * Creates a throttled function that only invokes `func` at most once per
171
+ * every `wait` milliseconds. The throttled function comes with a `cancel`
172
+ * method to cancel delayed `func` invocations and a `flush` method to
173
+ * immediately invoke them. Provide `options` to indicate whether `func`
174
+ * should be invoked on the leading and/or trailing edge of the `wait`
175
+ * timeout. The `func` is invoked with the last arguments provided to the
176
+ * throttled function. Subsequent calls to the throttled function return the
177
+ * result of the last `func` invocation.
178
+ *
179
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
180
+ * invoked on the trailing edge of the timeout only if the throttled function
181
+ * is invoked more than once during the `wait` timeout.
182
+ *
183
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
184
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
185
+ *
186
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
187
+ * for details over the differences between `_.throttle` and `_.debounce`.
188
+ *
189
+ * @static
190
+ * @memberOf _
191
+ * @since 0.1.0
192
+ * @category Function
193
+ * @param {Function} func The function to throttle.
194
+ * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
195
+ * @param {Object} [options={}] The options object.
196
+ * @param {boolean} [options.leading=true]
197
+ * Specify invoking on the leading edge of the timeout.
198
+ * @param {boolean} [options.trailing=true]
199
+ * Specify invoking on the trailing edge of the timeout.
200
+ * @returns {Function} Returns the new throttled function.
201
+ * @example
202
+ *
203
+ * // Avoid excessively updating the position while scrolling.
204
+ * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
205
+ *
206
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
207
+ * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
208
+ * jQuery(element).on('click', throttled);
209
+ *
210
+ * // Cancel the trailing throttled invocation.
211
+ * jQuery(window).on('popstate', throttled.cancel);
212
+ */
213
+ function throttle(func, wait, options) {
214
+ var leading = true,
215
+ trailing = true;
216
+
217
+ if (typeof func != 'function') {
218
+ throw new TypeError(FUNC_ERROR_TEXT);
219
+ }
220
+ if (isObject(options)) {
221
+ leading = 'leading' in options ? !!options.leading : leading;
222
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
223
+ }
224
+ return debounce(func, wait, {
225
+ 'leading': leading,
226
+ 'maxWait': wait,
227
+ 'trailing': trailing
228
+ });
229
+ }
230
+
231
+ export { LocalScrollTimer as L, LocalScrollService as a, getContentSize as g, throttle as t };
232
+
5
233
  //# sourceMappingURL=throttle-dec28f5b.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["initialParams","contentSize","clientSize","virtualSize","maxSize","NO_COORDINATE","getContentSize","LocalScrollService","constructor","cfg","this","preventArtificialScroll","rgRow","rgCol","previousScroll","params","Object","assign","setParams","dimension","virtualContentSize","setScroll","e","cancelScroll","frameAnimation","Promise","resolve","reject","skipAnimationFrame","animationId","window","requestAnimationFrame","bind","getParams","coordinate","Math","ceil","wrapCoordinate","applyScroll","convert","id","cancelAnimationFrame","scroll","force","delta","outside","param","runScroll","c","_b","_a","call","pos","toReal","minRange","from","to","scaleValue","LocalScrollTimer","scrollThrottling","mouseWheelScrollTimestamp","lastKnownScrollCoordinate","setCoordinate","latestScrollUpdate","Date","getTime","isReady","type","change","FUNC_ERROR_TEXT","throttle","func","wait","options","leading","trailing","TypeError","isObject","debounce","maxWait"],"sources":["src/services/local.scroll.service.ts","src/services/local.scroll.timer.ts","node_modules/lodash/throttle.js"],"sourcesContent":["import type { DimensionType, ViewPortScrollEvent } from '@type';\nimport { scaleValue } from '../utils';\n\ninterface Config {\n skipAnimationFrame?: boolean;\n // scroll event inited and direction cached\n // scrollingService.proxyScroll get tiggered\n // setScroll event called from scrollingService\n runScroll(e: ViewPortScrollEvent): void;\n // all operation finished, apply scroll values\n applyScroll(e: ViewPortScrollEvent): void;\n}\n\ntype Params = {\n contentSize: number;\n virtualContentSize?: number;\n clientSize: number;\n virtualSize: number;\n maxSize?: number;\n};\n\nconst initialParams: Params = {\n contentSize: 0,\n clientSize: 0,\n virtualSize: 0,\n maxSize: 0,\n};\nconst NO_COORDINATE = -1;\n\n/**\n * Based on content size, client size and virtual size\n * return full size\n */\nexport function getContentSize(\n contentSize: number,\n clientSize: number,\n virtualSize = 0,\n): number {\n if (virtualSize > contentSize) {\n return 0;\n }\n return contentSize + (virtualSize ? clientSize - virtualSize : 0);\n}\n\nexport default class LocalScrollService {\n private preventArtificialScroll: Record<DimensionType, (() => void) | null> = {\n rgRow: null,\n rgCol: null,\n };\n // to check if scroll changed\n private previousScroll: Record<DimensionType, number> = {\n rgRow: NO_COORDINATE,\n rgCol: NO_COORDINATE,\n };\n private params: Record<DimensionType, Params> = {\n rgRow: { ...initialParams },\n rgCol: { ...initialParams },\n };\n\n constructor(private cfg: Config) {}\n\n setParams(params: Params, dimension: DimensionType) {\n const virtualContentSize = getContentSize(\n params.contentSize,\n params.clientSize,\n params.virtualSize,\n );\n this.params[dimension] = {\n ...params,\n maxSize: virtualContentSize - params.clientSize,\n virtualContentSize,\n };\n }\n\n // apply scroll values after scroll done\n async setScroll(e: ViewPortScrollEvent) {\n this.cancelScroll(e.dimension);\n\n // start frame animation\n const frameAnimation = new Promise<void>((resolve, reject) => {\n // for example safari desktop has issues with animation frame\n if (this.cfg.skipAnimationFrame) {\n return resolve();\n }\n const animationId = window.requestAnimationFrame(() => {\n resolve();\n });\n this.preventArtificialScroll[e.dimension] = reject.bind(\n null,\n animationId,\n );\n });\n\n try {\n await frameAnimation;\n const params = this.getParams(e.dimension);\n e.coordinate = Math.ceil(e.coordinate);\n this.previousScroll[e.dimension] = this.wrapCoordinate(\n e.coordinate,\n params,\n );\n this.preventArtificialScroll[e.dimension] = null;\n this.cfg.applyScroll({\n ...e,\n coordinate: params.virtualSize\n ? this.convert(e.coordinate, params, false)\n : e.coordinate,\n });\n } catch (id) {\n window.cancelAnimationFrame(id);\n }\n }\n\n /**\n * On scroll event started\n */\n scroll(\n coordinate: number,\n dimension: DimensionType,\n force = false,\n delta?: number,\n outside = false,\n ) {\n // cancel all previous scrolls for same dimension\n this.cancelScroll(dimension);\n\n // drop if no change\n if (!force && this.previousScroll[dimension] === coordinate) {\n this.previousScroll[dimension] = NO_COORDINATE;\n return;\n }\n\n const param = this.getParams(dimension);\n // let component know about scroll event started\n this.cfg.runScroll({\n dimension: dimension,\n coordinate: param.virtualSize\n ? this.convert(coordinate, param)\n : coordinate,\n delta,\n outside,\n });\n }\n\n private getParams(dimension: DimensionType): Params {\n return this.params[dimension];\n }\n\n // check if scroll outside of region to avoid looping\n private wrapCoordinate(c: number, param: Params): number {\n if (c < 0) {\n return NO_COORDINATE;\n }\n\n if (typeof param.maxSize === 'number' && c > param.maxSize) {\n return param.maxSize;\n }\n return c;\n }\n\n // prevent already started scroll, performance optimization\n private cancelScroll(dimension: DimensionType) {\n this.preventArtificialScroll[dimension]?.();\n this.preventArtificialScroll[dimension] = null;\n }\n\n /* convert virtual to real and back, scale range */\n private convert(pos: number, param: Params, toReal = true): number {\n const minRange = param.clientSize;\n const from: [number, number] = [0, (param.virtualContentSize ?? minRange) - minRange];\n const to: [number, number] = [0, param.contentSize - param.virtualSize];\n if (toReal) {\n return scaleValue(pos, from, to);\n }\n return scaleValue(pos, to, from);\n }\n}\n","import type { DimensionType } from '@type';\n/**\n * Apply changes only if mousewheel event happened some time ago (scrollThrottling)\n */\nexport class LocalScrollTimer {\n /**\n * Last mw event time for trigger scroll function below\n * If mousewheel function was ignored we still need to trigger render\n */\n private mouseWheelScrollTimestamp: Record<DimensionType, number> = {\n rgCol: 0,\n rgRow: 0,\n };\n private lastKnownScrollCoordinate: Record<DimensionType, number> = {\n rgCol: 0,\n rgRow: 0,\n };\n\n constructor(private scrollThrottling = 10) {}\n\n setCoordinate(e: { dimension: DimensionType; coordinate: number }) {\n this.lastKnownScrollCoordinate[e.dimension] = e.coordinate;\n }\n\n /**\n * Remember last mw event time\n */\n latestScrollUpdate(dimension: DimensionType) {\n this.mouseWheelScrollTimestamp[dimension] = new Date().getTime();\n }\n\n /**\n * Check if scroll is ready to accept new value\n */\n isReady(type: DimensionType, coordinate: number) {\n const change = new Date().getTime() - this.mouseWheelScrollTimestamp[type];\n // apply after throttling\n return (\n change > this.scrollThrottling &&\n coordinate !== this.lastKnownScrollCoordinate[type]\n );\n }\n}\n","import debounce from './debounce.js';\nimport isObject from './isObject.js';\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\nfunction throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n 'leading': leading,\n 'maxWait': wait,\n 'trailing': trailing\n });\n}\n\nexport default throttle;\n"],"mappings":";;;sGAqBA,MAAMA,EAAwB,CAC5BC,YAAa,EACbC,WAAY,EACZC,YAAa,EACbC,QAAS,GAEX,MAAMC,GAAiB,E,SAMPC,EACdL,EACAC,EACAC,EAAc,GAEd,GAAIA,EAAcF,EAAa,CAC7B,OAAO,C,CAET,OAAOA,GAAeE,EAAcD,EAAaC,EAAc,EACjE,C,MAEqBI,EAenB,WAAAC,CAAoBC,GAAAC,KAAAD,MAdZC,KAAAC,wBAAsE,CAC5EC,MAAO,KACPC,MAAO,MAGDH,KAAAI,eAAgD,CACtDF,MAAOP,EACPQ,MAAOR,GAEDK,KAAAK,OAAwC,CAC9CH,MAAKI,OAAAC,OAAA,GAAOjB,GACZa,MAAKG,OAAAC,OAAA,GAAOjB,G,CAKd,SAAAkB,CAAUH,EAAgBI,GACxB,MAAMC,EAAqBd,EACzBS,EAAOd,YACPc,EAAOb,WACPa,EAAOZ,aAETO,KAAKK,OAAOI,GAAUH,OAAAC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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;AACvC,EAAE,IAAI,OAAO,GAAG,IAAI;AACpB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB;AACA,EAAE,IAAI,OAAO,IAAI,IAAI,UAAU,EAAE;AACjC,IAAI,MAAM,IAAI,SAAS,CAAC,eAAe,CAAC,CAAC;AACzC,GAAG;AACH,EAAE,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE;AACzB,IAAI,OAAO,GAAG,SAAS,IAAI,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AACjE,IAAI,QAAQ,GAAG,UAAU,IAAI,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACrE,GAAG;AACH,EAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE;AAC9B,IAAI,SAAS,EAAE,OAAO;AACtB,IAAI,SAAS,EAAE,IAAI;AACnB,IAAI,UAAU,EAAE,QAAQ;AACxB,GAAG,CAAC,CAAC;AACL;;;;","names":[],"sources":["src/services/local.scroll.service.ts","src/services/local.scroll.timer.ts","node_modules/lodash/throttle.js"],"sourcesContent":["import type { DimensionType, ViewPortScrollEvent } from '@type';\nimport { scaleValue } from '../utils';\n\ninterface Config {\n skipAnimationFrame?: boolean;\n // scroll event inited and direction cached\n // scrollingService.proxyScroll get tiggered\n // setScroll event called from scrollingService\n runScroll(e: ViewPortScrollEvent): void;\n // all operation finished, apply scroll values\n applyScroll(e: ViewPortScrollEvent): void;\n}\n\ntype Params = {\n contentSize: number;\n virtualContentSize?: number;\n clientSize: number;\n virtualSize: number;\n maxSize?: number;\n};\n\nconst initialParams: Params = {\n contentSize: 0,\n clientSize: 0,\n virtualSize: 0,\n maxSize: 0,\n};\nconst NO_COORDINATE = -1;\n\n/**\n * Based on content size, client size and virtual size\n * return full size\n */\nexport function getContentSize(\n contentSize: number,\n clientSize: number,\n virtualSize = 0,\n): number {\n if (virtualSize > contentSize) {\n return 0;\n }\n return contentSize + (virtualSize ? clientSize - virtualSize : 0);\n}\n\nexport default class LocalScrollService {\n private preventArtificialScroll: Record<DimensionType, (() => void) | null> = {\n rgRow: null,\n rgCol: null,\n };\n // to check if scroll changed\n private previousScroll: Record<DimensionType, number> = {\n rgRow: NO_COORDINATE,\n rgCol: NO_COORDINATE,\n };\n private params: Record<DimensionType, Params> = {\n rgRow: { ...initialParams },\n rgCol: { ...initialParams },\n };\n\n constructor(private cfg: Config) {}\n\n setParams(params: Params, dimension: DimensionType) {\n const virtualContentSize = getContentSize(\n params.contentSize,\n params.clientSize,\n params.virtualSize,\n );\n this.params[dimension] = {\n ...params,\n maxSize: virtualContentSize - params.clientSize,\n virtualContentSize,\n };\n }\n\n // apply scroll values after scroll done\n async setScroll(e: ViewPortScrollEvent) {\n this.cancelScroll(e.dimension);\n\n // start frame animation\n const frameAnimation = new Promise<void>((resolve, reject) => {\n // for example safari desktop has issues with animation frame\n if (this.cfg.skipAnimationFrame) {\n return resolve();\n }\n const animationId = window.requestAnimationFrame(() => {\n resolve();\n });\n this.preventArtificialScroll[e.dimension] = reject.bind(\n null,\n animationId,\n );\n });\n\n try {\n await frameAnimation;\n const params = this.getParams(e.dimension);\n e.coordinate = Math.ceil(e.coordinate);\n this.previousScroll[e.dimension] = this.wrapCoordinate(\n e.coordinate,\n params,\n );\n this.preventArtificialScroll[e.dimension] = null;\n this.cfg.applyScroll({\n ...e,\n coordinate: params.virtualSize\n ? this.convert(e.coordinate, params, false)\n : e.coordinate,\n });\n } catch (id) {\n window.cancelAnimationFrame(id);\n }\n }\n\n /**\n * On scroll event started\n */\n scroll(\n coordinate: number,\n dimension: DimensionType,\n force = false,\n delta?: number,\n outside = false,\n ) {\n // cancel all previous scrolls for same dimension\n this.cancelScroll(dimension);\n\n // drop if no change\n if (!force && this.previousScroll[dimension] === coordinate) {\n this.previousScroll[dimension] = NO_COORDINATE;\n return;\n }\n\n const param = this.getParams(dimension);\n // let component know about scroll event started\n this.cfg.runScroll({\n dimension: dimension,\n coordinate: param.virtualSize\n ? this.convert(coordinate, param)\n : coordinate,\n delta,\n outside,\n });\n }\n\n private getParams(dimension: DimensionType): Params {\n return this.params[dimension];\n }\n\n // check if scroll outside of region to avoid looping\n private wrapCoordinate(c: number, param: Params): number {\n if (c < 0) {\n return NO_COORDINATE;\n }\n\n if (typeof param.maxSize === 'number' && c > param.maxSize) {\n return param.maxSize;\n }\n return c;\n }\n\n // prevent already started scroll, performance optimization\n private cancelScroll(dimension: DimensionType) {\n this.preventArtificialScroll[dimension]?.();\n this.preventArtificialScroll[dimension] = null;\n }\n\n /* convert virtual to real and back, scale range */\n private convert(pos: number, param: Params, toReal = true): number {\n const minRange = param.clientSize;\n const from: [number, number] = [0, (param.virtualContentSize ?? minRange) - minRange];\n const to: [number, number] = [0, param.contentSize - param.virtualSize];\n if (toReal) {\n return scaleValue(pos, from, to);\n }\n return scaleValue(pos, to, from);\n }\n}\n","import type { DimensionType } from '@type';\n/**\n * Apply changes only if mousewheel event happened some time ago (scrollThrottling)\n */\nexport class LocalScrollTimer {\n /**\n * Last mw event time for trigger scroll function below\n * If mousewheel function was ignored we still need to trigger render\n */\n private mouseWheelScrollTimestamp: Record<DimensionType, number> = {\n rgCol: 0,\n rgRow: 0,\n };\n private lastKnownScrollCoordinate: Record<DimensionType, number> = {\n rgCol: 0,\n rgRow: 0,\n };\n\n constructor(private scrollThrottling = 10) {}\n\n setCoordinate(e: { dimension: DimensionType; coordinate: number }) {\n this.lastKnownScrollCoordinate[e.dimension] = e.coordinate;\n }\n\n /**\n * Remember last mw event time\n */\n latestScrollUpdate(dimension: DimensionType) {\n this.mouseWheelScrollTimestamp[dimension] = new Date().getTime();\n }\n\n /**\n * Check if scroll is ready to accept new value\n */\n isReady(type: DimensionType, coordinate: number) {\n const change = new Date().getTime() - this.mouseWheelScrollTimestamp[type];\n // apply after throttling\n return (\n change > this.scrollThrottling &&\n coordinate !== this.lastKnownScrollCoordinate[type]\n );\n }\n}\n","import debounce from './debounce.js';\nimport isObject from './isObject.js';\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\nfunction throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n 'leading': leading,\n 'maxWait': wait,\n 'trailing': trailing\n });\n}\n\nexport default throttle;\n"],"version":3}
@@ -1,5 +1,52 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- const t="header";const o="footer";const n="content";const e="data";function a(t,o){const n=t.viewports[t.colType].store.get("realCount");const e=t.viewports[o].store.get("realCount");return{x:n,y:e}}function s(t,o,n,e){return{colData:t.colStore,viewportCol:t.viewports[t.colType].store,viewportRow:t.viewports[o].store,lastCell:a(t,o),slot:n,type:o,canDrag:!e,position:t.position,dataStore:t.rowStores[o].store,dimensionCol:t.dimensions[t.colType].store,dimensionRow:t.dimensions[o].store,style:e?{height:`${t.dimensions[o].store.get("realSize")}px`}:undefined}}export{n as C,e as D,o as F,t as H,s as v};
4
+ /**
5
+ * Collects data for pinned columns in the required @ViewportProps format.
6
+ */
7
+ /**
8
+ * Represents the slot names for the viewport slots.
9
+ */
10
+ const HEADER_SLOT = 'header'; // Slot name for the header slot
11
+ const FOOTER_SLOT = 'footer'; // Slot name for the footer slot
12
+ const CONTENT_SLOT = 'content'; // Slot name for the content slot
13
+ const DATA_SLOT = 'data'; // Slot name for the data slot
14
+ /**
15
+ * Returns the last visible cell in the viewport for a given row type.
16
+ * Coordinates are not zero-based and are relative to the viewport.
17
+ * If needed to be zero-based they can be adjusted by subtracting 1.
18
+ */
19
+ function getLastCell(data, rowType) {
20
+ // Get the last visible column count from the viewport column data.
21
+ const lastVisibleColumnCount = data.viewports[data.colType].store.get('realCount');
22
+ // Get the last visible row count for the given row type from the viewport column data.
23
+ const lastVisibleRowCount = data.viewports[rowType].store.get('realCount');
24
+ // Return the last visible cell with the last visible column count and row count.
25
+ return {
26
+ x: lastVisibleColumnCount,
27
+ y: lastVisibleRowCount,
28
+ };
29
+ }
30
+ function viewportDataPartition(data, type, slot, fixed) {
31
+ return {
32
+ colData: data.colStore,
33
+ viewportCol: data.viewports[data.colType].store,
34
+ viewportRow: data.viewports[type].store,
35
+ // lastCell is the last real coordinate + 1
36
+ lastCell: getLastCell(data, type),
37
+ slot,
38
+ type,
39
+ canDrag: !fixed,
40
+ position: data.position,
41
+ dataStore: data.rowStores[type].store,
42
+ dimensionCol: data.dimensions[data.colType].store,
43
+ dimensionRow: data.dimensions[type].store,
44
+ style: fixed
45
+ ? { height: `${data.dimensions[type].store.get('realSize')}px` }
46
+ : undefined,
47
+ };
48
+ }
49
+
50
+ export { CONTENT_SLOT as C, DATA_SLOT as D, FOOTER_SLOT as F, HEADER_SLOT as H, viewportDataPartition as v };
51
+
5
52
  //# sourceMappingURL=viewport.helpers-7e7f9dad.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["HEADER_SLOT","FOOTER_SLOT","CONTENT_SLOT","DATA_SLOT","getLastCell","data","rowType","lastVisibleColumnCount","viewports","colType","store","get","lastVisibleRowCount","x","y","viewportDataPartition","type","slot","fixed","colData","colStore","viewportCol","viewportRow","lastCell","canDrag","position","dataStore","rowStores","dimensionCol","dimensions","dimensionRow","style","height","undefined"],"sources":["src/components/revoGrid/viewport.helpers.ts"],"sourcesContent":["/**\n * Collects data for pinned columns in the required @ViewportProps format.\n */\n\nimport type {\n DimensionRows,\n MultiDimensionType,\n SlotType,\n Cell,\n ViewportColumn,\n ColumnRegular,\n DimensionCols,\n ViewportState,\n DimensionSettingsState,\n DataType,\n} from '@type';\nimport type { Observable } from '../../utils';\nimport type { DSourceState } from '../../store';\n/**\n * Represents the slot names for the viewport slots.\n */\nexport const HEADER_SLOT = 'header'; // Slot name for the header slot\nexport const FOOTER_SLOT = 'footer'; // Slot name for the footer slot\nexport const CONTENT_SLOT = 'content'; // Slot name for the content slot\nexport const DATA_SLOT = 'data'; // Slot name for the data slot\n\n/**\n * Returns the last visible cell in the viewport for a given row type.\n * Coordinates are not zero-based and are relative to the viewport.\n * If needed to be zero-based they can be adjusted by subtracting 1.\n */\nexport function getLastCell(\n data: ViewportColumn,\n rowType: MultiDimensionType,\n): Cell {\n // Get the last visible column count from the viewport column data.\n const lastVisibleColumnCount = data.viewports[data.colType].store.get('realCount');\n\n // Get the last visible row count for the given row type from the viewport column data.\n const lastVisibleRowCount = data.viewports[rowType].store.get('realCount');\n\n // Return the last visible cell with the last visible column count and row count.\n return {\n x: lastVisibleColumnCount,\n y: lastVisibleRowCount,\n };\n}\n\n/**\n * Represents the partition of viewport data.\n */\nexport type VPPartition = {\n colData: Observable<DSourceState<ColumnRegular, DimensionCols>>;\n viewportCol: Observable<ViewportState>;\n viewportRow: Observable<ViewportState>;\n lastCell: Cell;\n slot: SlotType;\n type: DimensionRows;\n canDrag: boolean;\n position: Cell;\n dataStore: Observable<DSourceState<DataType, DimensionRows>>;\n dimensionCol: Observable<DimensionSettingsState>;\n dimensionRow: Observable<DimensionSettingsState>;\n style?: { height: string };\n};\n\nexport function viewportDataPartition(\n data: ViewportColumn,\n type: DimensionRows,\n slot: SlotType,\n fixed?: boolean,\n): VPPartition {\n return {\n colData: data.colStore,\n viewportCol: data.viewports[data.colType].store,\n viewportRow: data.viewports[type].store,\n // lastCell is the last real coordinate + 1\n lastCell: getLastCell(data, type),\n slot,\n type,\n canDrag: !fixed,\n position: data.position,\n dataStore: data.rowStores[type].store,\n dimensionCol: data.dimensions[data.colType].store,\n dimensionRow: data.dimensions[type].store,\n style: fixed\n ? { height: `${data.dimensions[type].store.get('realSize')}px` }\n : undefined,\n };\n}\n"],"mappings":";;;MAqBaA,EAAc,S,MACdC,EAAc,S,MACdC,EAAe,U,MACfC,EAAY,O,SAOTC,EACdC,EACAC,GAGA,MAAMC,EAAyBF,EAAKG,UAAUH,EAAKI,SAASC,MAAMC,IAAI,aAGtE,MAAMC,EAAsBP,EAAKG,UAAUF,GAASI,MAAMC,IAAI,aAG9D,MAAO,CACLE,EAAGN,EACHO,EAAGF,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,CAAC,IAAI,CAAC,CAAC,KAAK;;QAEvC,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI;QACJ,IAAI;QACJ,OAAO,EAAE,CAAC,KAAK;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK;QACrC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK;QACjD,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK;QACzC,KAAK,EAAE,KAAK;cACR,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE;cAC9D,SAAS;KACd,CAAC;AACJ;;;;","names":[],"sources":["src/components/revoGrid/viewport.helpers.ts"],"sourcesContent":["/**\n * Collects data for pinned columns in the required @ViewportProps format.\n */\n\nimport type {\n DimensionRows,\n MultiDimensionType,\n SlotType,\n Cell,\n ViewportColumn,\n ColumnRegular,\n DimensionCols,\n ViewportState,\n DimensionSettingsState,\n DataType,\n} from '@type';\nimport type { Observable } from '../../utils';\nimport type { DSourceState } from '../../store';\n/**\n * Represents the slot names for the viewport slots.\n */\nexport const HEADER_SLOT = 'header'; // Slot name for the header slot\nexport const FOOTER_SLOT = 'footer'; // Slot name for the footer slot\nexport const CONTENT_SLOT = 'content'; // Slot name for the content slot\nexport const DATA_SLOT = 'data'; // Slot name for the data slot\n\n/**\n * Returns the last visible cell in the viewport for a given row type.\n * Coordinates are not zero-based and are relative to the viewport.\n * If needed to be zero-based they can be adjusted by subtracting 1.\n */\nexport function getLastCell(\n data: ViewportColumn,\n rowType: MultiDimensionType,\n): Cell {\n // Get the last visible column count from the viewport column data.\n const lastVisibleColumnCount = data.viewports[data.colType].store.get('realCount');\n\n // Get the last visible row count for the given row type from the viewport column data.\n const lastVisibleRowCount = data.viewports[rowType].store.get('realCount');\n\n // Return the last visible cell with the last visible column count and row count.\n return {\n x: lastVisibleColumnCount,\n y: lastVisibleRowCount,\n };\n}\n\n/**\n * Represents the partition of viewport data.\n */\nexport type VPPartition = {\n colData: Observable<DSourceState<ColumnRegular, DimensionCols>>;\n viewportCol: Observable<ViewportState>;\n viewportRow: Observable<ViewportState>;\n lastCell: Cell;\n slot: SlotType;\n type: DimensionRows;\n canDrag: boolean;\n position: Cell;\n dataStore: Observable<DSourceState<DataType, DimensionRows>>;\n dimensionCol: Observable<DimensionSettingsState>;\n dimensionRow: Observable<DimensionSettingsState>;\n style?: { height: string };\n};\n\nexport function viewportDataPartition(\n data: ViewportColumn,\n type: DimensionRows,\n slot: SlotType,\n fixed?: boolean,\n): VPPartition {\n return {\n colData: data.colStore,\n viewportCol: data.viewports[data.colType].store,\n viewportRow: data.viewports[type].store,\n // lastCell is the last real coordinate + 1\n lastCell: getLastCell(data, type),\n slot,\n type,\n canDrag: !fixed,\n position: data.position,\n dataStore: data.rowStores[type].store,\n dimensionCol: data.dimensions[data.colType].store,\n dimensionRow: data.dimensions[type].store,\n style: fixed\n ? { height: `${data.dimensions[type].store.get('realSize')}px` }\n : undefined,\n };\n}\n"],"version":3}