@revolist/revogrid 3.1.6 → 3.2.4

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 (213) hide show
  1. package/dist/revo-grid/_baseIteratee-af30b221.js +2070 -0
  2. package/dist/{collection/global/global.js → revo-grid/app-globals-7e6866ba.js} +11 -2
  3. package/dist/{collection/components/data/columnService.js → revo-grid/columnService-91e552ba.js} +11 -6
  4. package/dist/revo-grid/consts-ef824e6f.js +46 -0
  5. package/dist/revo-grid/css-shim-5387c708.js +7 -0
  6. package/dist/revo-grid/data.store-3263fff9.js +557 -0
  7. package/dist/revo-grid/debounce-aaa4b4da.js +217 -0
  8. package/dist/revo-grid/dimension.helpers-a7944fc4.js +340 -0
  9. package/dist/revo-grid/dispatcher-891af82e.js +24 -0
  10. package/dist/{cjs/dom-c8b6d1a7.js → revo-grid/dom-21bd1807.js} +4 -3
  11. package/dist/revo-grid/each-0378e5a3.js +180 -0
  12. package/dist/{collection/plugins/filter/filter.button.js → revo-grid/filter.button-74c1cd9c.js} +16 -10
  13. package/dist/revo-grid/identity-c8c7d3d8.js +26 -0
  14. package/dist/revo-grid/index-8a604c17.js +3067 -0
  15. package/dist/revo-grid/index.esm.js +3 -0
  16. package/dist/revo-grid/isString-a51066b5.js +34 -0
  17. package/dist/revo-grid/isSymbol-e4b5dafe.js +247 -0
  18. package/dist/revo-grid/keyCodes.utils-bd06e3ba.js +299 -0
  19. package/dist/revo-grid/keys-70b7c240.js +561 -0
  20. package/dist/{collection/services/localScrollService.js → revo-grid/localScrollService-e9b73323.js} +8 -2
  21. package/dist/{esm/revo-grid_11.entry.js → revo-grid/lodash-a0ab4cdd.js} +13773 -24597
  22. package/dist/{cjs/resize-observer-8dc80084.js → revo-grid/resize-observer-00c48d78.js} +25 -14
  23. package/dist/revo-grid/revo-grid.entry.js +3484 -0
  24. package/dist/revo-grid/revo-grid.esm.js +133 -1
  25. package/dist/revo-grid/revogr-clipboard.entry.js +52 -1
  26. package/dist/revo-grid/revogr-data.entry.js +152 -0
  27. package/dist/revo-grid/revogr-edit.entry.js +105 -0
  28. package/dist/revo-grid/revogr-filter-panel.entry.js +277 -1
  29. package/dist/revo-grid/revogr-focus.entry.js +41 -0
  30. package/dist/revo-grid/revogr-header.entry.js +560 -0
  31. package/dist/revo-grid/revogr-order-editor.entry.js +175 -0
  32. package/dist/revo-grid/revogr-overlay-selection.entry.js +711 -0
  33. package/dist/revo-grid/revogr-row-headers.entry.js +73 -0
  34. package/dist/revo-grid/revogr-scroll-virtual.entry.js +114 -0
  35. package/dist/revo-grid/revogr-temp-range.entry.js +73 -0
  36. package/dist/revo-grid/revogr-viewport-scroll.entry.js +340 -0
  37. package/dist/revo-grid/selection.store.connector-2b613fd0.js +503 -0
  38. package/dist/{collection/components/overlay/selection.utils.js → revo-grid/selection.utils-a9932db6.js} +15 -9
  39. package/dist/revo-grid/shadow-css-602a09db.js +390 -0
  40. package/dist/{collection/themeManager/themeService.js → revo-grid/themeService-ddaaa364.js} +26 -6
  41. package/dist/revo-grid/toInteger-9e6cbfd2.js +107 -0
  42. package/dist/revo-grid/toNumber-913b0b72.js +105 -0
  43. package/dist/{collection/utils/utils.js → revo-grid/utils-2c3b3857.js} +13 -8
  44. package/dist/revo-grid/viewport.helpers-49d3f031.js +16 -0
  45. package/dist/{collection/store/viewPort/viewport.helpers.js → revo-grid/viewport.store-ffaaab6d.js} +135 -9
  46. package/dist/types/components/revo-grid/revo-grid.d.ts +6 -0
  47. package/dist/types/components.d.ts +110 -58
  48. package/dist/types/plugins/dispatcher.d.ts +10 -0
  49. package/dist/types/plugins/moveColumn/columnDragPlugin.d.ts +66 -0
  50. package/dist/types/plugins/moveColumn/columnOrderHandler.d.ts +12 -0
  51. package/dist/types/services/resizable.directive.d.ts +1 -1
  52. package/dist/types/stencil-public-runtime.d.ts +189 -186
  53. package/package.json +22 -20
  54. package/custom-element/index.js +0 -28972
  55. package/custom-element/resize-observer.js +0 -489
  56. package/dist/cjs/css-shim-e33df79c.js +0 -6
  57. package/dist/cjs/debounce-e9b040d9.js +0 -575
  58. package/dist/cjs/index-d3f67f2e.js +0 -1729
  59. package/dist/cjs/index.cjs.js +0 -2
  60. package/dist/cjs/loader.cjs.js +0 -35
  61. package/dist/cjs/revo-grid.cjs.js +0 -73
  62. package/dist/cjs/revo-grid_11.cjs.entry.js +0 -28056
  63. package/dist/cjs/revogr-clipboard.cjs.entry.js +0 -53
  64. package/dist/cjs/revogr-filter-panel.cjs.entry.js +0 -275
  65. package/dist/collection/collection-manifest.json +0 -25
  66. package/dist/collection/components/button/button.js +0 -4
  67. package/dist/collection/components/clipboard/revogr-clipboard.js +0 -121
  68. package/dist/collection/components/data/cellRenderer.js +0 -24
  69. package/dist/collection/components/data/revogr-data-style.css +0 -135
  70. package/dist/collection/components/data/revogr-data.js +0 -322
  71. package/dist/collection/components/data/rowRenderer.js +0 -6
  72. package/dist/collection/components/header/headerCellRenderer.js +0 -19
  73. package/dist/collection/components/header/headerRenderer.js +0 -45
  74. package/dist/collection/components/header/revogr-header-style.css +0 -198
  75. package/dist/collection/components/header/revogr-header.js +0 -297
  76. package/dist/collection/components/order/orderRenderer.js +0 -50
  77. package/dist/collection/components/order/revogr-order-editor.js +0 -358
  78. package/dist/collection/components/order/rowOrderService.js +0 -68
  79. package/dist/collection/components/overlay/autofill.service.js +0 -182
  80. package/dist/collection/components/overlay/clipboard.service.js +0 -39
  81. package/dist/collection/components/overlay/editors/edit.utils.js +0 -5
  82. package/dist/collection/components/overlay/editors/text.js +0 -35
  83. package/dist/collection/components/overlay/keyboard.service.js +0 -128
  84. package/dist/collection/components/overlay/revogr-edit-style.css +0 -86
  85. package/dist/collection/components/overlay/revogr-edit.js +0 -159
  86. package/dist/collection/components/overlay/revogr-overlay-selection.js +0 -726
  87. package/dist/collection/components/overlay/revogr-overlay-style.css +0 -98
  88. package/dist/collection/components/revo-grid/revo-grid-style.css +0 -527
  89. package/dist/collection/components/revo-grid/revo-grid.js +0 -2186
  90. package/dist/collection/components/revo-grid/viewport.helpers.js +0 -11
  91. package/dist/collection/components/revo-grid/viewport.interfaces.js +0 -1
  92. package/dist/collection/components/revo-grid/viewport.js +0 -18
  93. package/dist/collection/components/revo-grid/viewport.resize.service.js +0 -21
  94. package/dist/collection/components/revo-grid/viewport.scrolling.service.js +0 -60
  95. package/dist/collection/components/revo-grid/viewport.section.js +0 -28
  96. package/dist/collection/components/revo-grid/viewport.service.js +0 -209
  97. package/dist/collection/components/rowHeaders/revogr-row-headers.js +0 -210
  98. package/dist/collection/components/rowHeaders/row-header-render.js +0 -1
  99. package/dist/collection/components/scroll/revogr-viewport-scroll-style.css +0 -137
  100. package/dist/collection/components/scroll/revogr-viewport-scroll.js +0 -399
  101. package/dist/collection/components/scrollable/revogr-scroll-style.css +0 -104
  102. package/dist/collection/components/scrollable/revogr-scroll-virtual.js +0 -253
  103. package/dist/collection/components/selection-focus/revogr-focus-style.css +0 -77
  104. package/dist/collection/components/selection-focus/revogr-focus.js +0 -103
  105. package/dist/collection/components/selection-temp-range/revogr-temp-range-style.css +0 -98
  106. package/dist/collection/components/selection-temp-range/revogr-temp-range.js +0 -138
  107. package/dist/collection/index.js +0 -1
  108. package/dist/collection/plugins/autoSizeColumn.js +0 -230
  109. package/dist/collection/plugins/basePlugin.js +0 -27
  110. package/dist/collection/plugins/export/csv.js +0 -68
  111. package/dist/collection/plugins/export/export.plugin.js +0 -165
  112. package/dist/collection/plugins/export/types.js +0 -1
  113. package/dist/collection/plugins/filter/conditions/equal.js +0 -17
  114. package/dist/collection/plugins/filter/conditions/number/greaterThan.js +0 -10
  115. package/dist/collection/plugins/filter/conditions/number/greaterThanOrEqual.js +0 -7
  116. package/dist/collection/plugins/filter/conditions/number/lessThan.js +0 -12
  117. package/dist/collection/plugins/filter/conditions/number/lessThanOrEqual.js +0 -7
  118. package/dist/collection/plugins/filter/conditions/set.js +0 -3
  119. package/dist/collection/plugins/filter/conditions/string/beginswith.js +0 -17
  120. package/dist/collection/plugins/filter/conditions/string/contains.js +0 -18
  121. package/dist/collection/plugins/filter/filter.plugin.js +0 -256
  122. package/dist/collection/plugins/filter/filter.pop.js +0 -485
  123. package/dist/collection/plugins/filter/filter.service.js +0 -44
  124. package/dist/collection/plugins/filter/filter.style.css +0 -239
  125. package/dist/collection/plugins/filter/filter.types.js +0 -1
  126. package/dist/collection/plugins/groupingColumn/columnGroupsRenderer.js +0 -30
  127. package/dist/collection/plugins/groupingColumn/grouping.col.plugin.js +0 -36
  128. package/dist/collection/plugins/groupingColumn/headerGroupRenderer.js +0 -21
  129. package/dist/collection/plugins/groupingRow/grouping.const.js +0 -10
  130. package/dist/collection/plugins/groupingRow/grouping.row.expand.service.js +0 -76
  131. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +0 -258
  132. package/dist/collection/plugins/groupingRow/grouping.row.renderer.js +0 -29
  133. package/dist/collection/plugins/groupingRow/grouping.row.types.js +0 -1
  134. package/dist/collection/plugins/groupingRow/grouping.service.js +0 -155
  135. package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js +0 -57
  136. package/dist/collection/plugins/sorting/sorting.plugin.js +0 -181
  137. package/dist/collection/plugins/sorting/sorting.sign.js +0 -6
  138. package/dist/collection/plugins/stretchPlugin.js +0 -68
  139. package/dist/collection/plugins/trimmed/trimmed.plugin.js +0 -32
  140. package/dist/collection/services/cell.helpers.js +0 -7
  141. package/dist/collection/services/column.data.provider.js +0 -188
  142. package/dist/collection/services/data.provider.js +0 -47
  143. package/dist/collection/services/dimension.provider.js +0 -78
  144. package/dist/collection/services/resizable.directive.js +0 -250
  145. package/dist/collection/services/selection.store.connector.js +0 -213
  146. package/dist/collection/services/viewport.provider.js +0 -14
  147. package/dist/collection/store/dataSource/data.proxy.js +0 -34
  148. package/dist/collection/store/dataSource/data.store.js +0 -127
  149. package/dist/collection/store/dimension/dimension.helpers.js +0 -107
  150. package/dist/collection/store/dimension/dimension.store.js +0 -59
  151. package/dist/collection/store/selection/selection.helpers.js +0 -53
  152. package/dist/collection/store/selection/selection.store.js +0 -68
  153. package/dist/collection/store/selection/selection.store.service.js +0 -35
  154. package/dist/collection/store/storeTypes.js +0 -5
  155. package/dist/collection/store/viewPort/viewport.store.js +0 -121
  156. package/dist/collection/themeManager/theme.compact.js +0 -5
  157. package/dist/collection/themeManager/theme.default.js +0 -5
  158. package/dist/collection/themeManager/theme.material.js +0 -5
  159. package/dist/collection/utils/closestPolifill.js +0 -18
  160. package/dist/collection/utils/consts.js +0 -19
  161. package/dist/collection/utils/generateAlphabetHeader.js +0 -20
  162. package/dist/collection/utils/keyCodes.js +0 -70
  163. package/dist/collection/utils/keyCodes.utils.js +0 -64
  164. package/dist/collection/utils/platform.js +0 -5
  165. package/dist/collection/utils/resizeObserver.js +0 -6
  166. package/dist/collection/utils/store.utils.js +0 -7
  167. package/dist/collection/utilsExternal/generate-data.js +0 -132
  168. package/dist/esm/css-shim-8d75038b.js +0 -4
  169. package/dist/esm/debounce-8dadcda7.js +0 -558
  170. package/dist/esm/dom-1b195079.js +0 -73
  171. package/dist/esm/index-42c84e7c.js +0 -1694
  172. package/dist/esm/index.js +0 -1
  173. package/dist/esm/loader.js +0 -31
  174. package/dist/esm/polyfills/core-js.js +0 -11
  175. package/dist/esm/polyfills/css-shim.js +0 -1
  176. package/dist/esm/polyfills/dom.js +0 -79
  177. package/dist/esm/polyfills/es5-html-element.js +0 -1
  178. package/dist/esm/polyfills/index.js +0 -34
  179. package/dist/esm/polyfills/system.js +0 -6
  180. package/dist/esm/resize-observer-56b7b34f.js +0 -489
  181. package/dist/esm/revo-grid.js +0 -71
  182. package/dist/esm/revogr-clipboard.entry.js +0 -49
  183. package/dist/esm/revogr-filter-panel.entry.js +0 -271
  184. package/dist/esm-es5/css-shim-8d75038b.js +0 -1
  185. package/dist/esm-es5/debounce-8dadcda7.js +0 -1
  186. package/dist/esm-es5/dom-1b195079.js +0 -21
  187. package/dist/esm-es5/index-42c84e7c.js +0 -1
  188. package/dist/esm-es5/index.js +0 -0
  189. package/dist/esm-es5/loader.js +0 -1
  190. package/dist/esm-es5/resize-observer-56b7b34f.js +0 -1
  191. package/dist/esm-es5/revo-grid.js +0 -1
  192. package/dist/esm-es5/revo-grid_11.entry.js +0 -1
  193. package/dist/esm-es5/revogr-clipboard.entry.js +0 -1
  194. package/dist/esm-es5/revogr-filter-panel.entry.js +0 -1
  195. package/dist/index.cjs.js +0 -1
  196. package/dist/index.js +0 -1
  197. package/dist/revo-grid/css-shim-88bfb262.system.js +0 -1
  198. package/dist/revo-grid/css-shim-8d75038b.js +0 -1
  199. package/dist/revo-grid/debounce-d097578d.js +0 -1
  200. package/dist/revo-grid/debounce-f40a88f6.system.js +0 -1
  201. package/dist/revo-grid/dom-1b195079.js +0 -19
  202. package/dist/revo-grid/dom-ee2dd1b3.system.js +0 -21
  203. package/dist/revo-grid/index-a15e7527.system.js +0 -1
  204. package/dist/revo-grid/index-a7f99799.js +0 -1
  205. package/dist/revo-grid/index.system.js +0 -1
  206. package/dist/revo-grid/resize-observer-56b7b34f.js +0 -1
  207. package/dist/revo-grid/resize-observer-7a7b9757.system.js +0 -1
  208. package/dist/revo-grid/revo-grid.js +0 -132
  209. package/dist/revo-grid/revo-grid.system.js +0 -1
  210. package/dist/revo-grid/revo-grid_11.entry.js +0 -1
  211. package/dist/revo-grid/revo-grid_11.system.entry.js +0 -1
  212. package/dist/revo-grid/revogr-clipboard.system.entry.js +0 -1
  213. package/dist/revo-grid/revogr-filter-panel.system.entry.js +0 -1
@@ -0,0 +1,3484 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import { h, r as registerInstance, e as createEvent, f as Host, g as getElement } from './index-8a604c17.js';
5
+ import { r as reduce_1, c as calculateDimensionData, g as getItemByIndex, a as getItemByPosition } from './dimension.helpers-a7944fc4.js';
6
+ import { _ as _baseEach, e as each } from './each-0378e5a3.js';
7
+ import { _ as _baseIteratee, a as _baseProperty, b as _getTag } from './_baseIteratee-af30b221.js';
8
+ import { i as isArrayLike_1, k as keys_1, a as isArray_1, _ as _baseKeys } from './keys-70b7c240.js';
9
+ import { f as findIndex_1, D as DataStore, g as getSourceItem, a as getSourceItemVirtualIndexByProp, s as setSourceByVirtualIndex, b as getVisibleSourceItem, c as createStore, d as setStore, _ as _isIterateeCall, e as gatherTrimmedItems, h as getPhysical, i as setItems } from './data.store-3263fff9.js';
10
+ import { _ as _arrayMap, U as UUID } from './consts-ef824e6f.js';
11
+ import { V as ViewportStore } from './viewport.store-ffaaab6d.js';
12
+ import { T as ThemeService } from './themeService-ddaaa364.js';
13
+ import { t as timeout, g as getScrollbarWidth } from './utils-2c3b3857.js';
14
+ import { i as isFilterBtn, F as FILTER_PROP } from './filter.button-74c1cd9c.js';
15
+ import { i as isString_1 } from './isString-a51066b5.js';
16
+ import { t as toInteger_1 } from './toInteger-9e6cbfd2.js';
17
+ import { i as isGrouping, g as getGroupingName, P as PSEUDO_GROUP_ITEM_ID, G as GROUP_EXPANDED, a as getParsedGroup, b as isSameGroup, c as GROUP_DEPTH, d as GROUPING_ROW_TYPE, e as PSEUDO_GROUP_ITEM_VALUE, f as PSEUDO_GROUP_COLUMN, h as GROUP_EXPAND_EVENT, j as gatherGrouping, k as isGroupingColumn, E as EMPTY_INDEX, S as SelectionStoreConnector } from './selection.store.connector-2b613fd0.js';
18
+ import { H as HEADER_SLOT, C as CONTENT_SLOT, F as FOOTER_SLOT, g as getLastCell, D as DATA_SLOT } from './viewport.helpers-49d3f031.js';
19
+ import { l as lodash } from './lodash-a0ab4cdd.js';
20
+ import { d as debounce_1 } from './debounce-aaa4b4da.js';
21
+ import { d as dispatch } from './dispatcher-891af82e.js';
22
+ import './isSymbol-e4b5dafe.js';
23
+ import './identity-c8c7d3d8.js';
24
+ import './toNumber-913b0b72.js';
25
+
26
+ /**
27
+ * Creates a `_.find` or `_.findLast` function.
28
+ *
29
+ * @private
30
+ * @param {Function} findIndexFunc The function to find the collection index.
31
+ * @returns {Function} Returns the new find function.
32
+ */
33
+ function createFind(findIndexFunc) {
34
+ return function(collection, predicate, fromIndex) {
35
+ var iterable = Object(collection);
36
+ if (!isArrayLike_1(collection)) {
37
+ var iteratee = _baseIteratee(predicate, 3);
38
+ collection = keys_1(collection);
39
+ predicate = function(key) { return iteratee(iterable[key], key, iterable); };
40
+ }
41
+ var index = findIndexFunc(collection, predicate, fromIndex);
42
+ return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
43
+ };
44
+ }
45
+
46
+ var _createFind = createFind;
47
+
48
+ /**
49
+ * Iterates over elements of `collection`, returning the first element
50
+ * `predicate` returns truthy for. The predicate is invoked with three
51
+ * arguments: (value, index|key, collection).
52
+ *
53
+ * @static
54
+ * @memberOf _
55
+ * @since 0.1.0
56
+ * @category Collection
57
+ * @param {Array|Object} collection The collection to inspect.
58
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
59
+ * @param {number} [fromIndex=0] The index to search from.
60
+ * @returns {*} Returns the matched element, else `undefined`.
61
+ * @example
62
+ *
63
+ * var users = [
64
+ * { 'user': 'barney', 'age': 36, 'active': true },
65
+ * { 'user': 'fred', 'age': 40, 'active': false },
66
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
67
+ * ];
68
+ *
69
+ * _.find(users, function(o) { return o.age < 40; });
70
+ * // => object for 'barney'
71
+ *
72
+ * // The `_.matches` iteratee shorthand.
73
+ * _.find(users, { 'age': 1, 'active': true });
74
+ * // => object for 'pebbles'
75
+ *
76
+ * // The `_.matchesProperty` iteratee shorthand.
77
+ * _.find(users, ['active', false]);
78
+ * // => object for 'fred'
79
+ *
80
+ * // The `_.property` iteratee shorthand.
81
+ * _.find(users, 'active');
82
+ * // => object for 'barney'
83
+ */
84
+ var find = _createFind(findIndex_1);
85
+
86
+ var find_1 = find;
87
+
88
+ const rowTypes = ['rowPinStart', 'rgRow', 'rowPinEnd'];
89
+ const columnTypes = ['colPinStart', 'rgCol', 'colPinEnd'];
90
+ function isRowType(type) {
91
+ return rowTypes.indexOf(type) > -1;
92
+ }
93
+
94
+ /**
95
+ * The base implementation of `_.map` without support for iteratee shorthands.
96
+ *
97
+ * @private
98
+ * @param {Array|Object} collection The collection to iterate over.
99
+ * @param {Function} iteratee The function invoked per iteration.
100
+ * @returns {Array} Returns the new mapped array.
101
+ */
102
+ function baseMap(collection, iteratee) {
103
+ var index = -1,
104
+ result = isArrayLike_1(collection) ? Array(collection.length) : [];
105
+
106
+ _baseEach(collection, function(value, key, collection) {
107
+ result[++index] = iteratee(value, key, collection);
108
+ });
109
+ return result;
110
+ }
111
+
112
+ var _baseMap = baseMap;
113
+
114
+ /**
115
+ * Creates an array of values by running each element in `collection` thru
116
+ * `iteratee`. The iteratee is invoked with three arguments:
117
+ * (value, index|key, collection).
118
+ *
119
+ * Many lodash methods are guarded to work as iteratees for methods like
120
+ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
121
+ *
122
+ * The guarded methods are:
123
+ * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
124
+ * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
125
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
126
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
127
+ *
128
+ * @static
129
+ * @memberOf _
130
+ * @since 0.1.0
131
+ * @category Collection
132
+ * @param {Array|Object} collection The collection to iterate over.
133
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
134
+ * @returns {Array} Returns the new mapped array.
135
+ * @example
136
+ *
137
+ * function square(n) {
138
+ * return n * n;
139
+ * }
140
+ *
141
+ * _.map([4, 8], square);
142
+ * // => [16, 64]
143
+ *
144
+ * _.map({ 'a': 4, 'b': 8 }, square);
145
+ * // => [16, 64] (iteration order is not guaranteed)
146
+ *
147
+ * var users = [
148
+ * { 'user': 'barney' },
149
+ * { 'user': 'fred' }
150
+ * ];
151
+ *
152
+ * // The `_.property` iteratee shorthand.
153
+ * _.map(users, 'user');
154
+ * // => ['barney', 'fred']
155
+ */
156
+ function map(collection, iteratee) {
157
+ var func = isArray_1(collection) ? _arrayMap : _baseMap;
158
+ return func(collection, _baseIteratee(iteratee, 3));
159
+ }
160
+
161
+ var map_1 = map;
162
+
163
+ class BasePlugin {
164
+ constructor(revogrid) {
165
+ this.revogrid = revogrid;
166
+ this.subscriptions = {};
167
+ }
168
+ addEventListener(name, func) {
169
+ this.revogrid.addEventListener(name, func);
170
+ this.subscriptions[name] = func;
171
+ }
172
+ removeEventListener(type) {
173
+ this.revogrid.removeEventListener(type, this.subscriptions[type]);
174
+ delete this.subscriptions[type];
175
+ }
176
+ emit(eventName, detail) {
177
+ const event = new CustomEvent(eventName, { detail: detail, cancelable: true });
178
+ this.revogrid.dispatchEvent(event);
179
+ return event;
180
+ }
181
+ clearSubscriptions() {
182
+ for (let type in this.subscriptions) {
183
+ this.removeEventListener(type);
184
+ }
185
+ }
186
+ destroy() {
187
+ this.clearSubscriptions();
188
+ }
189
+ }
190
+
191
+ class GroupingColumnPlugin extends BasePlugin {
192
+ static gatherGroup(res, colData, collection, level = 0) {
193
+ // group template
194
+ const group = Object.assign(Object.assign({}, colData), { level, ids: [] });
195
+ // check columns for update
196
+ for (let k in collection.columns) {
197
+ const key = k;
198
+ const resultItem = res.columns[key];
199
+ const collectionItem = collection.columns[key];
200
+ // if column data
201
+ if (isArray_1(resultItem) && isArray_1(collectionItem)) {
202
+ // fill columns
203
+ resultItem.push(...collectionItem);
204
+ // fill grouping
205
+ if (collectionItem.length) {
206
+ res.columnGrouping[key].push(Object.assign(Object.assign({}, group), { ids: map_1(collectionItem, 'prop') }));
207
+ }
208
+ }
209
+ }
210
+ // merge column groupings
211
+ for (let k in collection.columnGrouping) {
212
+ const key = k;
213
+ const collectionItem = collection.columnGrouping[key];
214
+ res.columnGrouping[key].push(...collectionItem);
215
+ }
216
+ res.maxLevel = Math.max(res.maxLevel, collection.maxLevel);
217
+ res.sort = Object.assign(Object.assign({}, res.sort), collection.sort);
218
+ return res;
219
+ }
220
+ static isColGrouping(colData) {
221
+ return !!colData.children;
222
+ }
223
+ }
224
+
225
+ class ColumnDataProvider {
226
+ constructor() {
227
+ this.sorting = null;
228
+ this.dataSources = reduce_1(columnTypes, (sources, k) => {
229
+ sources[k] = new DataStore(k);
230
+ return sources;
231
+ }, {});
232
+ }
233
+ get order() {
234
+ return reduce_1(this.sorting, (r, c, prop) => {
235
+ r[prop] = c.order;
236
+ return r;
237
+ }, {});
238
+ }
239
+ get stores() {
240
+ return this.dataSources;
241
+ }
242
+ column(c, pin) {
243
+ return this.getColumn(c, pin || 'rgCol');
244
+ }
245
+ getColumn(virtualIndex, type) {
246
+ return getSourceItem(this.dataSources[type].store, virtualIndex);
247
+ }
248
+ getRawColumns() {
249
+ return reduce_1(this.dataSources, (result, item, type) => {
250
+ result[type] = item.store.get('source');
251
+ return result;
252
+ }, {
253
+ rgCol: [],
254
+ colPinStart: [],
255
+ colPinEnd: []
256
+ });
257
+ }
258
+ getColumns(type = 'all') {
259
+ if (type !== 'all') {
260
+ return this.dataSources[type].store.get('source');
261
+ }
262
+ return columnTypes.reduce((r, t) => {
263
+ r.push(...this.dataSources[t].store.get('source'));
264
+ return r;
265
+ }, []);
266
+ }
267
+ getColumnIndexByProp(prop, type) {
268
+ return getSourceItemVirtualIndexByProp(this.dataSources[type].store, prop);
269
+ }
270
+ getColumnByProp(prop, type) {
271
+ const items = this.dataSources[type].store.get('source');
272
+ return find_1(items, { prop });
273
+ }
274
+ refreshByType(type) {
275
+ this.dataSources[type].refresh();
276
+ }
277
+ setColumns(data) {
278
+ each(columnTypes, k => {
279
+ // set columns data
280
+ this.dataSources[k].updateData(data.columns[k], {
281
+ // max depth level
282
+ depth: data.maxLevel,
283
+ // groups
284
+ groups: reduce_1(data.columnGrouping[k], (res, g) => {
285
+ if (!res[g.level]) {
286
+ res[g.level] = [];
287
+ }
288
+ res[g.level].push(g);
289
+ return res;
290
+ }, {}),
291
+ });
292
+ });
293
+ this.sorting = data.sort;
294
+ return data;
295
+ }
296
+ updateColumns(cols) {
297
+ // collect column by type and propert
298
+ const columnByKey = cols.reduce((res, c) => {
299
+ const type = ColumnDataProvider.getColumnType(c);
300
+ if (!res[type]) {
301
+ res[type] = {};
302
+ }
303
+ res[type][c.prop] = c;
304
+ return res;
305
+ }, {});
306
+ // find indexes in source
307
+ const colByIndex = {};
308
+ each(columnByKey, (colsToUpdate, type) => {
309
+ const items = this.dataSources[type].store.get('source');
310
+ colByIndex[type] = items.reduce((result, rgCol, index) => {
311
+ const colToUpdateIfExists = colsToUpdate[rgCol.prop];
312
+ if (colToUpdateIfExists) {
313
+ result[index] = colToUpdateIfExists;
314
+ }
315
+ return result;
316
+ }, {});
317
+ });
318
+ each(colByIndex, (colsToUpdate, type) => setSourceByVirtualIndex(this.dataSources[type].store, colsToUpdate));
319
+ }
320
+ updateColumn(column, index) {
321
+ const type = ColumnDataProvider.getColumnType(column);
322
+ setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });
323
+ }
324
+ updateColumnSorting(column, index, sorting, additive) {
325
+ if (!additive) {
326
+ this.clearSorting();
327
+ }
328
+ column.order = sorting;
329
+ this.sorting[column.prop] = column;
330
+ this.updateColumn(column, index);
331
+ return column;
332
+ }
333
+ clearSorting() {
334
+ const types = reduce_1(this.sorting, (r, c) => {
335
+ const k = ColumnDataProvider.getColumnType(c);
336
+ r[k] = true;
337
+ return r;
338
+ }, {});
339
+ each(types, (_, type) => {
340
+ const cols = this.dataSources[type].store.get('source');
341
+ each(cols, (c) => (c.order = undefined));
342
+ this.dataSources[type].setData({ source: [...cols] });
343
+ });
344
+ this.sorting = {};
345
+ }
346
+ static getSizes(cols) {
347
+ return reduce_1(cols, (res, c, i) => {
348
+ if (c.size) {
349
+ res[i] = c.size;
350
+ }
351
+ return res;
352
+ }, {});
353
+ }
354
+ static getColumnByProp(columns, prop) {
355
+ return find_1(columns, c => {
356
+ if (GroupingColumnPlugin.isColGrouping(c)) {
357
+ return ColumnDataProvider.getColumnByProp(c.children, prop);
358
+ }
359
+ return c.prop === prop;
360
+ });
361
+ }
362
+ // columns processing
363
+ static getColumns(columns, level = 0, types) {
364
+ return reduce_1(columns, (res, colData) => {
365
+ /** Grouped column */
366
+ if (GroupingColumnPlugin.isColGrouping(colData)) {
367
+ return GroupingColumnPlugin.gatherGroup(res, colData, ColumnDataProvider.getColumns(colData.children, level + 1, types), level);
368
+ }
369
+ /** Regular column */
370
+ const regularColumn = Object.assign(Object.assign({}, (colData.columnType && types && types[colData.columnType])), colData);
371
+ // not pin
372
+ if (!regularColumn.pin) {
373
+ res.columns.rgCol.push(regularColumn);
374
+ // pin
375
+ }
376
+ else {
377
+ res.columns[regularColumn.pin].push(regularColumn);
378
+ }
379
+ if (regularColumn.order) {
380
+ res.sort[regularColumn.prop] = regularColumn;
381
+ }
382
+ // trigger setup hook if present
383
+ regularColumn.beforeSetup && regularColumn.beforeSetup(regularColumn);
384
+ return res;
385
+ }, {
386
+ columns: {
387
+ rgCol: [],
388
+ colPinStart: [],
389
+ colPinEnd: [],
390
+ },
391
+ columnGrouping: {
392
+ rgCol: [],
393
+ colPinStart: [],
394
+ colPinEnd: [],
395
+ },
396
+ maxLevel: level,
397
+ sort: {},
398
+ });
399
+ }
400
+ static getColumnType(rgCol) {
401
+ if (rgCol.pin) {
402
+ return rgCol.pin;
403
+ }
404
+ return 'rgCol';
405
+ }
406
+ }
407
+
408
+ class DataProvider {
409
+ constructor(dimensionProvider) {
410
+ this.dimensionProvider = dimensionProvider;
411
+ this.stores = reduce_1(rowTypes, (sources, k) => {
412
+ sources[k] = new DataStore(k);
413
+ return sources;
414
+ }, {});
415
+ }
416
+ setData(data, type = 'rgRow', grouping, silent = false) {
417
+ // set rgRow data
418
+ this.stores[type].updateData([...data], grouping, silent);
419
+ this.dimensionProvider.setData(data, type, type !== 'rgRow');
420
+ return data;
421
+ }
422
+ getModel(virtualIndex, type = 'rgRow') {
423
+ const store = this.stores[type].store;
424
+ return getSourceItem(store, virtualIndex);
425
+ }
426
+ setCellData({ type, rowIndex, prop, val }) {
427
+ const model = this.getModel(rowIndex, type);
428
+ model[prop] = val;
429
+ setSourceByVirtualIndex(this.stores[type].store, { [rowIndex]: model });
430
+ }
431
+ refresh(type = 'all') {
432
+ if (isRowType(type)) {
433
+ this.refreshItems(type);
434
+ }
435
+ rowTypes.forEach((t) => this.refreshItems(t));
436
+ }
437
+ refreshItems(type = 'rgRow') {
438
+ const items = this.stores[type].store.get('items');
439
+ this.stores[type].setData({ items: [...items] });
440
+ }
441
+ setGrouping({ depth }, type = 'rgRow') {
442
+ this.stores[type].setData({ groupingDepth: depth });
443
+ }
444
+ setTrimmed(trimmed, type = 'rgRow') {
445
+ const store = this.stores[type];
446
+ store.addTrimmed(trimmed);
447
+ if (type === 'rgRow') {
448
+ this.dimensionProvider.setData(getVisibleSourceItem(store.store), type);
449
+ }
450
+ }
451
+ }
452
+
453
+ /**
454
+ * Storing pre-calculated
455
+ * Dimension information and sizes
456
+ */
457
+ function initialBase() {
458
+ return {
459
+ indexes: [],
460
+ // item index to size
461
+ sizes: {},
462
+ // order in indexes[] to coordinate
463
+ positionIndexToItem: {},
464
+ // initial element to coordinate ^
465
+ indexToItem: {},
466
+ positionIndexes: []
467
+ };
468
+ }
469
+ function initialState() {
470
+ return Object.assign(Object.assign({}, initialBase()), {
471
+ // size which all items can take
472
+ realSize: 0,
473
+ // initial item size if it wasn't changed
474
+ originItemSize: 0, frameOffset: 0 });
475
+ }
476
+ class DimensionStore {
477
+ constructor() {
478
+ this.store = createStore(initialState());
479
+ }
480
+ getCurrentState() {
481
+ const state = initialState();
482
+ const keys = Object.keys(state);
483
+ return reduce_1(keys, (r, k) => {
484
+ const data = this.store.get(k);
485
+ r[k] = data;
486
+ return r;
487
+ }, state);
488
+ }
489
+ setRealSize(count) {
490
+ let realSize = 0;
491
+ for (let i = 0; i < count; i++) {
492
+ realSize += this.store.get('sizes')[i] || this.store.get('originItemSize');
493
+ }
494
+ setStore(this.store, { realSize });
495
+ }
496
+ setStore(data) {
497
+ setStore(this.store, data);
498
+ }
499
+ drop() {
500
+ setStore(this.store, initialBase());
501
+ }
502
+ setDimensionSize(sizes) {
503
+ const dimensionData = calculateDimensionData(this.getCurrentState(), sizes);
504
+ setStore(this.store, dimensionData);
505
+ return dimensionData;
506
+ }
507
+ }
508
+
509
+ class DimensionProvider {
510
+ constructor(viewports) {
511
+ this.viewports = viewports;
512
+ this.stores = reduce_1([...rowTypes, ...columnTypes], (sources, k) => {
513
+ sources[k] = new DimensionStore();
514
+ return sources;
515
+ }, {});
516
+ }
517
+ setDimensionSize(dimensionType, sizes) {
518
+ this.stores[dimensionType].setDimensionSize(sizes);
519
+ this.viewports.stores[dimensionType].setViewPortDimension(sizes);
520
+ }
521
+ setRealSize(realCount, type) {
522
+ this.viewports.stores[type].setViewport({ realCount });
523
+ this.stores[type].setRealSize(realCount);
524
+ }
525
+ /**
526
+ * Sets dimension data and view port coordinate
527
+ * @param items - data/column items
528
+ * @param type - dimension type
529
+ */
530
+ setData(items, type, noVirtual = false) {
531
+ this.setRealSize(items.length, type);
532
+ if (noVirtual) {
533
+ this.setNoVirtual(type);
534
+ }
535
+ this.setViewPortCoordinate({
536
+ coordinate: this.viewports.stores[type].store.get('lastCoordinate'),
537
+ type,
538
+ });
539
+ }
540
+ setNoVirtual(type) {
541
+ const dimension = this.stores[type].getCurrentState();
542
+ this.viewports.stores[type].setViewport({ virtualSize: dimension.realSize });
543
+ }
544
+ drop() {
545
+ for (let type of columnTypes) {
546
+ this.stores[type].drop();
547
+ }
548
+ }
549
+ setColumns(type, sizes, noVirtual = false) {
550
+ this.stores[type].setDimensionSize(sizes);
551
+ if (noVirtual) {
552
+ this.setNoVirtual(type);
553
+ }
554
+ this.setViewPortCoordinate({
555
+ coordinate: this.viewports.stores[type].store.get('lastCoordinate'),
556
+ type,
557
+ });
558
+ }
559
+ setViewPortCoordinate({ coordinate, type }) {
560
+ const dimension = this.stores[type].getCurrentState();
561
+ this.viewports.stores[type].setViewPortCoordinate(coordinate, dimension);
562
+ }
563
+ getViewPortPos(e) {
564
+ const dimension = this.stores[e.dimension].getCurrentState();
565
+ const item = getItemByIndex(dimension, e.coordinate);
566
+ return item.start;
567
+ }
568
+ setSettings(data, dimensionType) {
569
+ let stores = [];
570
+ switch (dimensionType) {
571
+ case 'rgCol':
572
+ stores = columnTypes;
573
+ break;
574
+ case 'rgRow':
575
+ stores = rowTypes;
576
+ break;
577
+ }
578
+ for (let s of stores) {
579
+ this.stores[s].setStore(data);
580
+ }
581
+ }
582
+ }
583
+
584
+ class ViewportProvider {
585
+ constructor() {
586
+ this.stores = reduce_1([...rowTypes, ...columnTypes], (sources, k) => {
587
+ sources[k] = new ViewportStore();
588
+ return sources;
589
+ }, {});
590
+ }
591
+ setViewport(dimensionType, data) {
592
+ this.stores[dimensionType].setViewport(data);
593
+ }
594
+ }
595
+
596
+ /**
597
+ * Plugin module for revo-grid grid system
598
+ * Add support for automatic column resize
599
+ */
600
+ const LETTER_BLOCK_SIZE = 7;
601
+ var ColumnAutoSizeMode;
602
+ (function (ColumnAutoSizeMode) {
603
+ // increases column width on header click according the largest text value
604
+ ColumnAutoSizeMode["headerClickAutosize"] = "headerClickAutoSize";
605
+ // increases column width on data set and text edit, decreases performance
606
+ ColumnAutoSizeMode["autoSizeOnTextOverlap"] = "autoSizeOnTextOverlap";
607
+ // increases and decreases column width based on all items sizes, worst for performance
608
+ ColumnAutoSizeMode["autoSizeAll"] = "autoSizeAll";
609
+ })(ColumnAutoSizeMode || (ColumnAutoSizeMode = {}));
610
+ class AutoSizeColumn extends BasePlugin {
611
+ constructor(revogrid, providers, config) {
612
+ super(revogrid);
613
+ this.providers = providers;
614
+ this.config = config;
615
+ this.autoSizeColumns = null;
616
+ /** for edge case when no columns defined before data */
617
+ this.dataResolve = null;
618
+ this.dataReject = null;
619
+ this.letterBlockSize = (config === null || config === void 0 ? void 0 : config.letterBlockSize) || LETTER_BLOCK_SIZE;
620
+ // create test container to check text width
621
+ if (config === null || config === void 0 ? void 0 : config.preciseSize) {
622
+ this.precsizeCalculationArea = this.initiatePresizeElement();
623
+ revogrid.appendChild(this.precsizeCalculationArea);
624
+ }
625
+ const aftersourceset = ({ detail: { source } }) => {
626
+ this.setSource(source);
627
+ };
628
+ const afteredit = ({ detail }) => {
629
+ this.afteredit(detail);
630
+ };
631
+ const afterEditAll = ({ detail }) => {
632
+ this.afterEditAll(detail);
633
+ };
634
+ const beforecolumnsset = ({ detail: { columns } }) => {
635
+ this.columnSet(columns);
636
+ };
637
+ const headerDblClick = ({ detail }) => {
638
+ const type = ColumnDataProvider.getColumnType(detail);
639
+ const size = this.getColumnSize(detail.index, type);
640
+ if (size) {
641
+ this.providers.dimensionProvider.setDimensionSize(type, {
642
+ [detail.index]: size,
643
+ });
644
+ }
645
+ };
646
+ this.addEventListener('beforecolumnsset', beforecolumnsset);
647
+ switch (config === null || config === void 0 ? void 0 : config.mode) {
648
+ case ColumnAutoSizeMode.autoSizeOnTextOverlap:
649
+ this.addEventListener('aftersourceset', aftersourceset);
650
+ this.addEventListener('afteredit', afteredit);
651
+ break;
652
+ case ColumnAutoSizeMode.autoSizeAll:
653
+ this.addEventListener('aftersourceset', aftersourceset);
654
+ this.addEventListener('afteredit', afterEditAll);
655
+ break;
656
+ default:
657
+ this.addEventListener('headerdblClick', headerDblClick);
658
+ break;
659
+ }
660
+ }
661
+ async setSource(source) {
662
+ let autoSize = this.autoSizeColumns;
663
+ if (this.dataReject) {
664
+ this.dataReject();
665
+ this.clearPromise();
666
+ }
667
+ /** If data set first and no column provided await until get one */
668
+ if (!autoSize) {
669
+ const request = new Promise((resolve, reject) => {
670
+ this.dataResolve = resolve;
671
+ this.dataReject = reject;
672
+ });
673
+ try {
674
+ autoSize = await request;
675
+ }
676
+ catch (e) {
677
+ return;
678
+ }
679
+ }
680
+ // calculate sizes
681
+ each(autoSize, (_v, type) => {
682
+ const sizes = {};
683
+ each(autoSize[type], rgCol => {
684
+ // calculate size
685
+ rgCol.size = sizes[rgCol.index] = source.reduce((prev, rgRow) => Math.max(prev, this.getLength(rgRow[rgCol.prop])), 0);
686
+ });
687
+ this.providers.dimensionProvider.setDimensionSize(type, sizes);
688
+ });
689
+ }
690
+ getLength(len) {
691
+ var _a;
692
+ const padding = 15;
693
+ if (!len) {
694
+ return 0;
695
+ }
696
+ try {
697
+ const str = len.toString();
698
+ /**if exact calculation required proxy with html element, slow operation */
699
+ if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.preciseSize) {
700
+ this.precsizeCalculationArea.innerText = str;
701
+ return this.precsizeCalculationArea.scrollWidth + padding * 2;
702
+ }
703
+ return str.length * this.letterBlockSize + padding * 2;
704
+ }
705
+ catch (e) {
706
+ return 0;
707
+ }
708
+ }
709
+ afteredit(e) {
710
+ let data;
711
+ if (this.isRangeEdit(e)) {
712
+ data = e.data;
713
+ }
714
+ else {
715
+ data = { 0: { [e.prop]: e.val } };
716
+ }
717
+ each(this.autoSizeColumns, (columns, type) => {
718
+ const sizes = {};
719
+ each(columns, rgCol => {
720
+ // calculate size
721
+ const size = reduce_1(data, (prev, rgRow) => {
722
+ if (typeof rgRow[rgCol.prop] === 'undefined') {
723
+ return prev;
724
+ }
725
+ return Math.max(prev || 0, this.getLength(rgRow[rgCol.prop]));
726
+ }, undefined);
727
+ if (size && rgCol.size < size) {
728
+ rgCol.size = sizes[rgCol.index] = size;
729
+ }
730
+ });
731
+ this.providers.dimensionProvider.setDimensionSize(type, sizes);
732
+ });
733
+ }
734
+ afterEditAll(e) {
735
+ const props = {};
736
+ if (this.isRangeEdit(e)) {
737
+ each(e.data, r => each(r, (_v, p) => (props[p] = true)));
738
+ }
739
+ else {
740
+ props[e.prop] = true;
741
+ }
742
+ each(this.autoSizeColumns, (columns, type) => {
743
+ const sizes = {};
744
+ each(columns, rgCol => {
745
+ if (props[rgCol.prop]) {
746
+ const size = this.getColumnSize(rgCol.index, type);
747
+ if (size) {
748
+ sizes[rgCol.index] = size;
749
+ }
750
+ }
751
+ });
752
+ this.providers.dimensionProvider.setDimensionSize(type, sizes);
753
+ });
754
+ }
755
+ getColumnSize(index, type) {
756
+ const rgCol = this.autoSizeColumns[type][index];
757
+ if (!rgCol) {
758
+ return 0;
759
+ }
760
+ return reduce_1(this.providers.dataProvider.stores, (r, s) => {
761
+ const perStore = reduce_1(s.store.get('items'), (prev, _row, i) => {
762
+ const item = getSourceItem(s.store, i);
763
+ return Math.max(prev || 0, this.getLength(item[rgCol.prop]));
764
+ }, 0);
765
+ return Math.max(r, perStore);
766
+ }, rgCol.size || 0);
767
+ }
768
+ columnSet(columns) {
769
+ var _a;
770
+ for (let t of columnTypes) {
771
+ const type = t;
772
+ const cols = columns[type];
773
+ for (let i in cols) {
774
+ if (cols[i].autoSize || ((_a = this.config) === null || _a === void 0 ? void 0 : _a.allColumns)) {
775
+ if (!this.autoSizeColumns) {
776
+ this.autoSizeColumns = {};
777
+ }
778
+ if (!this.autoSizeColumns[type]) {
779
+ this.autoSizeColumns[type] = {};
780
+ }
781
+ this.autoSizeColumns[type][i] = Object.assign(Object.assign({}, cols[i]), { index: parseInt(i, 10) });
782
+ }
783
+ }
784
+ }
785
+ if (this.dataResolve) {
786
+ this.dataResolve(this.autoSizeColumns);
787
+ this.clearPromise();
788
+ }
789
+ }
790
+ clearPromise() {
791
+ this.dataResolve = null;
792
+ this.dataReject = null;
793
+ }
794
+ isRangeEdit(e) {
795
+ return !!e.data;
796
+ }
797
+ initiatePresizeElement() {
798
+ const styleForFontTest = {
799
+ position: 'absolute',
800
+ fontSize: '14px',
801
+ height: '0',
802
+ width: '0',
803
+ whiteSpace: 'nowrap',
804
+ top: '0',
805
+ overflowX: 'scroll',
806
+ };
807
+ const el = document.createElement('div');
808
+ for (let s in styleForFontTest) {
809
+ el.style[s] = styleForFontTest[s];
810
+ }
811
+ el.classList.add('revo-test-container');
812
+ return el;
813
+ }
814
+ destroy() {
815
+ var _a;
816
+ super.destroy();
817
+ (_a = this.precsizeCalculationArea) === null || _a === void 0 ? void 0 : _a.remove();
818
+ }
819
+ }
820
+
821
+ const eq = (value, extra) => {
822
+ if (typeof value === 'undefined' || (value === null && !extra)) {
823
+ return true;
824
+ }
825
+ if (typeof value !== 'string') {
826
+ value = JSON.stringify(value);
827
+ }
828
+ const filterVal = extra.toString().toLocaleLowerCase();
829
+ if (filterVal.length === 0) {
830
+ return true;
831
+ }
832
+ return value.toLocaleLowerCase() === filterVal;
833
+ };
834
+ const notEq = (value, extra) => !eq(value, extra);
835
+ notEq.extra = 'input';
836
+ eq.extra = 'input';
837
+
838
+ const gtThan = function (value, extra) {
839
+ let conditionValue;
840
+ if (typeof value === 'number') {
841
+ conditionValue = parseFloat(extra === null || extra === void 0 ? void 0 : extra.toString());
842
+ return value > conditionValue;
843
+ }
844
+ return false;
845
+ };
846
+ gtThan.extra = 'input';
847
+
848
+ const gtThanEq = function (value, extra) {
849
+ return eq(value, extra) || gtThan(value, extra);
850
+ };
851
+ gtThanEq.extra = 'input';
852
+
853
+ const lt = function (value, extra) {
854
+ let conditionValue;
855
+ if (typeof value === 'number') {
856
+ conditionValue = parseFloat(extra === null || extra === void 0 ? void 0 : extra.toString());
857
+ return value < conditionValue;
858
+ }
859
+ else {
860
+ return false;
861
+ }
862
+ };
863
+ lt.extra = 'input';
864
+
865
+ const lsEq = function (value, extra) {
866
+ return eq(value, extra) || lt(value, extra);
867
+ };
868
+ lsEq.extra = 'input';
869
+
870
+ const set = (value) => !(value === '' || value === null || value === void 0);
871
+ const notSet = (value) => !set(value);
872
+
873
+ const beginsWith = (value, extra) => {
874
+ if (!value) {
875
+ return false;
876
+ }
877
+ if (!extra) {
878
+ return true;
879
+ }
880
+ if (typeof value !== 'string') {
881
+ value = JSON.stringify(value);
882
+ }
883
+ if (typeof extra !== 'string') {
884
+ extra = JSON.stringify(extra);
885
+ }
886
+ return value.toLocaleLowerCase().indexOf(extra.toLocaleLowerCase()) === 0;
887
+ };
888
+ beginsWith.extra = 'input';
889
+
890
+ const contains = (value, extra) => {
891
+ if (!value) {
892
+ return false;
893
+ }
894
+ if (extra) {
895
+ if (typeof value !== 'string') {
896
+ value = JSON.stringify(value);
897
+ }
898
+ return value.toLocaleLowerCase().indexOf(extra.toString().toLowerCase()) > -1;
899
+ }
900
+ return true;
901
+ };
902
+ const notContains = (value, extra) => {
903
+ return !contains(value, extra);
904
+ };
905
+ notContains.extra = 'input';
906
+ contains.extra = 'input';
907
+
908
+ const filterNames = {
909
+ none: 'None',
910
+ empty: 'Not set',
911
+ notEmpty: 'Set',
912
+ eq: 'Equal',
913
+ notEq: 'Not equal',
914
+ begins: 'Begins with',
915
+ contains: 'Contains',
916
+ notContains: 'Does not contain',
917
+ eqN: '=',
918
+ neqN: '!=',
919
+ gt: '>',
920
+ gte: '>=',
921
+ lt: '<',
922
+ lte: '<=',
923
+ };
924
+ const filterEntities = {
925
+ none: () => true,
926
+ empty: notSet,
927
+ notEmpty: set,
928
+ eq: eq,
929
+ notEq: notEq,
930
+ begins: beginsWith,
931
+ contains: contains,
932
+ notContains: notContains,
933
+ eqN: eq,
934
+ neqN: notEq,
935
+ gt: gtThan,
936
+ gte: gtThanEq,
937
+ lt: lt,
938
+ lte: lsEq,
939
+ };
940
+ const filterTypes = {
941
+ string: ['notEmpty', 'empty', 'eq', 'notEq', 'begins', 'contains', 'notContains'],
942
+ number: ['notEmpty', 'empty', 'eqN', 'neqN', 'gt', 'gte', 'lt', 'lte'],
943
+ };
944
+
945
+ const FILTER_TRIMMED_TYPE = 'filter';
946
+ class FilterPlugin extends BasePlugin {
947
+ constructor(revogrid, uiid, config) {
948
+ var _a;
949
+ super(revogrid);
950
+ this.revogrid = revogrid;
951
+ this.filterCollection = {};
952
+ this.multiFilterItems = {};
953
+ this.possibleFilters = Object.assign({}, filterTypes);
954
+ this.possibleFilterNames = Object.assign({}, filterNames);
955
+ this.possibleFilterEntities = Object.assign({}, filterEntities);
956
+ if (config) {
957
+ this.initConfig(config);
958
+ }
959
+ const headerclick = (e) => this.headerclick(e);
960
+ const aftersourceset = async () => {
961
+ const filterCollectionProps = Object.keys(this.filterCollection);
962
+ if (filterCollectionProps.length > 0) {
963
+ // handle old way of filtering by reworking FilterCollection to new MultiFilterItem
964
+ filterCollectionProps.forEach((prop, index) => {
965
+ if (!this.multiFilterItems[prop]) {
966
+ this.multiFilterItems[prop] = [
967
+ {
968
+ id: index,
969
+ type: this.filterCollection[prop].type,
970
+ value: this.filterCollection[prop].value,
971
+ relation: 'and',
972
+ },
973
+ ];
974
+ }
975
+ });
976
+ }
977
+ await this.runFiltering();
978
+ };
979
+ this.addEventListener('headerclick', headerclick);
980
+ this.addEventListener('aftersourceset', aftersourceset);
981
+ this.revogrid.registerVNode([
982
+ h("revogr-filter-panel", { uuid: `filter-${uiid}`, filterItems: this.multiFilterItems, filterNames: this.possibleFilterNames, filterEntities: this.possibleFilterEntities, filterCaptions: (_a = config === null || config === void 0 ? void 0 : config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), disableDynamicFiltering: config === null || config === void 0 ? void 0 : config.disableDynamicFiltering, ref: e => (this.pop = e) }),
983
+ ]);
984
+ }
985
+ initConfig(config) {
986
+ if (config.collection) {
987
+ this.filterCollection = Object.assign({}, config.collection);
988
+ }
989
+ if (config.multiFilterItems) {
990
+ this.multiFilterItems = Object.assign({}, config.multiFilterItems);
991
+ }
992
+ if (config.customFilters) {
993
+ for (let cType in config.customFilters) {
994
+ const cFilter = config.customFilters[cType];
995
+ if (!this.possibleFilters[cFilter.columnFilterType]) {
996
+ this.possibleFilters[cFilter.columnFilterType] = [];
997
+ }
998
+ this.possibleFilters[cFilter.columnFilterType].push(cType);
999
+ this.possibleFilterEntities[cType] = cFilter.func;
1000
+ this.possibleFilterNames[cType] = cFilter.name;
1001
+ }
1002
+ }
1003
+ /**
1004
+ * which filters has to be included/excluded
1005
+ * convinient way to exclude system filters
1006
+ */
1007
+ if (config.include) {
1008
+ const filters = {};
1009
+ for (let t in this.possibleFilters) {
1010
+ // validate filters, if appropriate function present
1011
+ const newTypes = this.possibleFilters[t].filter(f => config.include.indexOf(f) > -1);
1012
+ if (newTypes.length) {
1013
+ filters[t] = newTypes;
1014
+ }
1015
+ }
1016
+ // if any valid filters provided show them
1017
+ if (Object.keys(filters).length > 0) {
1018
+ this.possibleFilters = filters;
1019
+ }
1020
+ }
1021
+ if (config.localization) {
1022
+ if (config.localization.filterNames) {
1023
+ Object.entries(config.localization.filterNames).forEach(([k, v]) => {
1024
+ if (this.possibleFilterNames[k] != void 0) {
1025
+ this.possibleFilterNames[k] = v;
1026
+ }
1027
+ });
1028
+ }
1029
+ }
1030
+ }
1031
+ async headerclick(e) {
1032
+ var _a;
1033
+ const el = (_a = e.detail.originalEvent) === null || _a === void 0 ? void 0 : _a.target;
1034
+ if (!isFilterBtn(el)) {
1035
+ return;
1036
+ }
1037
+ e.preventDefault();
1038
+ // close if same
1039
+ const changes = await this.pop.getChanges();
1040
+ if (changes && (changes === null || changes === void 0 ? void 0 : changes.prop) === e.detail.prop) {
1041
+ this.pop.show();
1042
+ return;
1043
+ }
1044
+ // filter button clicked, open filter dialog
1045
+ const gridPos = this.revogrid.getBoundingClientRect();
1046
+ const buttonPos = el.getBoundingClientRect();
1047
+ const prop = e.detail.prop;
1048
+ this.pop.filterTypes = this.getColumnFilter(e.detail.filter);
1049
+ this.pop.show(Object.assign(Object.assign({}, this.filterCollection[prop]), { x: buttonPos.x - gridPos.x, y: buttonPos.y - gridPos.y + buttonPos.height, prop }));
1050
+ }
1051
+ getColumnFilter(type) {
1052
+ let filterType = 'string';
1053
+ if (!type) {
1054
+ return { [filterType]: this.possibleFilters[filterType] };
1055
+ }
1056
+ // if custom column filter
1057
+ if (this.isValidType(type)) {
1058
+ filterType = type;
1059
+ // if multiple filters applied
1060
+ }
1061
+ else if (typeof type === 'object' && type.length) {
1062
+ return type.reduce((r, multiType) => {
1063
+ if (this.isValidType(multiType)) {
1064
+ r[multiType] = this.possibleFilters[multiType];
1065
+ }
1066
+ return r;
1067
+ }, {});
1068
+ }
1069
+ return { [filterType]: this.possibleFilters[filterType] };
1070
+ }
1071
+ isValidType(type) {
1072
+ return !!(typeof type === 'string' && this.possibleFilters[type]);
1073
+ }
1074
+ // called on internal component change
1075
+ async onFilterChange(filterItems) {
1076
+ this.multiFilterItems = filterItems;
1077
+ this.runFiltering();
1078
+ }
1079
+ /**
1080
+ * Triggers grid filtering
1081
+ */
1082
+ async doFiltering(collection, items, columns, filterItems) {
1083
+ const columnsToUpdate = [];
1084
+ columns.forEach(rgCol => {
1085
+ const column = Object.assign({}, rgCol);
1086
+ const hasFilter = filterItems[column.prop];
1087
+ if (column[FILTER_PROP] && !hasFilter) {
1088
+ delete column[FILTER_PROP];
1089
+ columnsToUpdate.push(column);
1090
+ }
1091
+ if (!column[FILTER_PROP] && hasFilter) {
1092
+ columnsToUpdate.push(column);
1093
+ column[FILTER_PROP] = true;
1094
+ }
1095
+ });
1096
+ const itemsToFilter = this.getRowFilter(items, filterItems);
1097
+ // check is filter event prevented
1098
+ const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', { collection, itemsToFilter, source: items, filterItems });
1099
+ if (defaultPrevented) {
1100
+ return;
1101
+ }
1102
+ // check is trimmed event prevented
1103
+ const isAddedEvent = await this.revogrid.addTrimmed(detail.itemsToFilter, FILTER_TRIMMED_TYPE);
1104
+ if (isAddedEvent.defaultPrevented) {
1105
+ return;
1106
+ }
1107
+ // applies the hasFilter to the columns to show filter icon
1108
+ await this.revogrid.updateColumns(columnsToUpdate);
1109
+ this.emit('afterFilterApply');
1110
+ }
1111
+ async clearFiltering() {
1112
+ this.multiFilterItems = {};
1113
+ await this.runFiltering();
1114
+ }
1115
+ async runFiltering() {
1116
+ const collection = {};
1117
+ // handle old filterCollection to return the first filter only (if any) from multiFilterItems
1118
+ const filterProps = Object.keys(this.multiFilterItems);
1119
+ for (const prop of filterProps) {
1120
+ // check if we have any filter for a column
1121
+ if (this.multiFilterItems[prop].length > 0) {
1122
+ const firstFilterItem = this.multiFilterItems[prop][0];
1123
+ collection[prop] = {
1124
+ filter: filterEntities[firstFilterItem.type],
1125
+ type: firstFilterItem.type,
1126
+ value: firstFilterItem.value,
1127
+ };
1128
+ }
1129
+ }
1130
+ this.filterCollection = collection;
1131
+ const { source, columns } = await this.getData();
1132
+ const { defaultPrevented, detail } = this.emit('beforefilterapply', { collection: this.filterCollection, source, columns, filterItems: this.multiFilterItems });
1133
+ if (defaultPrevented) {
1134
+ return;
1135
+ }
1136
+ this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
1137
+ }
1138
+ async getData() {
1139
+ const source = await this.revogrid.getSource();
1140
+ const columns = await this.revogrid.getColumns();
1141
+ return {
1142
+ source,
1143
+ columns,
1144
+ };
1145
+ }
1146
+ getRowFilter(rows, filterItems) {
1147
+ const propKeys = Object.keys(filterItems);
1148
+ const trimmed = {};
1149
+ let propFilterSatisfiedCount = 0;
1150
+ let lastFilterResults = [];
1151
+ // each rows
1152
+ rows.forEach((model, rowIndex) => {
1153
+ // working on all props
1154
+ for (const prop of propKeys) {
1155
+ const propFilters = filterItems[prop];
1156
+ propFilterSatisfiedCount = 0;
1157
+ lastFilterResults = [];
1158
+ // testing each filter for a prop
1159
+ for (const [filterIndex, filterData] of propFilters.entries()) {
1160
+ // the filter LogicFunction based on the type
1161
+ const filter = filterEntities[filterData.type];
1162
+ // THE MAGIC OF FILTERING IS HERE
1163
+ if (filterData.relation === 'or') {
1164
+ lastFilterResults = [];
1165
+ if (filter(model[prop], filterData.value)) {
1166
+ continue;
1167
+ }
1168
+ propFilterSatisfiedCount++;
1169
+ }
1170
+ else {
1171
+ // 'and' relation will need to know the next filter
1172
+ // so we save this current filter to include it in the next filter
1173
+ lastFilterResults.push(!filter(model[prop], filterData.value));
1174
+ // check first if we have a filter on the next index to pair it with this current filter
1175
+ const nextFilterData = propFilters[filterIndex + 1];
1176
+ // stop the sequence if there is no next filter or if the next filter is not an 'and' relation
1177
+ if (!nextFilterData || nextFilterData.relation !== 'and') {
1178
+ // let's just continue since for sure propFilterSatisfiedCount cannot be satisfied
1179
+ if (lastFilterResults.indexOf(true) === -1) {
1180
+ lastFilterResults = [];
1181
+ continue;
1182
+ }
1183
+ // we need to add all of the lastFilterResults since we need to satisfy all
1184
+ propFilterSatisfiedCount += lastFilterResults.length;
1185
+ lastFilterResults = [];
1186
+ }
1187
+ }
1188
+ } // end of propFilters forEach
1189
+ // add to the list of removed/trimmed rows of filter condition is satisfied
1190
+ if (propFilterSatisfiedCount === propFilters.length)
1191
+ trimmed[rowIndex] = true;
1192
+ } // end of for-of propKeys
1193
+ });
1194
+ return trimmed;
1195
+ }
1196
+ }
1197
+
1198
+ /**
1199
+ * Gets the size of an ASCII `string`.
1200
+ *
1201
+ * @private
1202
+ * @param {string} string The string inspect.
1203
+ * @returns {number} Returns the string size.
1204
+ */
1205
+ var asciiSize = _baseProperty('length');
1206
+
1207
+ var _asciiSize = asciiSize;
1208
+
1209
+ /** Used to compose unicode character classes. */
1210
+ var rsAstralRange$1 = '\\ud800-\\udfff',
1211
+ rsComboMarksRange$1 = '\\u0300-\\u036f',
1212
+ reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
1213
+ rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
1214
+ rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
1215
+ rsVarRange$1 = '\\ufe0e\\ufe0f';
1216
+
1217
+ /** Used to compose unicode capture groups. */
1218
+ var rsZWJ$1 = '\\u200d';
1219
+
1220
+ /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
1221
+ var reHasUnicode = RegExp('[' + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + ']');
1222
+
1223
+ /**
1224
+ * Checks if `string` contains Unicode symbols.
1225
+ *
1226
+ * @private
1227
+ * @param {string} string The string to inspect.
1228
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1229
+ */
1230
+ function hasUnicode(string) {
1231
+ return reHasUnicode.test(string);
1232
+ }
1233
+
1234
+ var _hasUnicode = hasUnicode;
1235
+
1236
+ /** Used to compose unicode character classes. */
1237
+ var rsAstralRange = '\\ud800-\\udfff',
1238
+ rsComboMarksRange = '\\u0300-\\u036f',
1239
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
1240
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
1241
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
1242
+ rsVarRange = '\\ufe0e\\ufe0f';
1243
+
1244
+ /** Used to compose unicode capture groups. */
1245
+ var rsAstral = '[' + rsAstralRange + ']',
1246
+ rsCombo = '[' + rsComboRange + ']',
1247
+ rsFitz = '\\ud83c[\\udffb-\\udfff]',
1248
+ rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
1249
+ rsNonAstral = '[^' + rsAstralRange + ']',
1250
+ rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
1251
+ rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
1252
+ rsZWJ = '\\u200d';
1253
+
1254
+ /** Used to compose unicode regexes. */
1255
+ var reOptMod = rsModifier + '?',
1256
+ rsOptVar = '[' + rsVarRange + ']?',
1257
+ rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
1258
+ rsSeq = rsOptVar + reOptMod + rsOptJoin,
1259
+ rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
1260
+
1261
+ /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
1262
+ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
1263
+
1264
+ /**
1265
+ * Gets the size of a Unicode `string`.
1266
+ *
1267
+ * @private
1268
+ * @param {string} string The string inspect.
1269
+ * @returns {number} Returns the string size.
1270
+ */
1271
+ function unicodeSize(string) {
1272
+ var result = reUnicode.lastIndex = 0;
1273
+ while (reUnicode.test(string)) {
1274
+ ++result;
1275
+ }
1276
+ return result;
1277
+ }
1278
+
1279
+ var _unicodeSize = unicodeSize;
1280
+
1281
+ /**
1282
+ * Gets the number of symbols in `string`.
1283
+ *
1284
+ * @private
1285
+ * @param {string} string The string to inspect.
1286
+ * @returns {number} Returns the string size.
1287
+ */
1288
+ function stringSize(string) {
1289
+ return _hasUnicode(string)
1290
+ ? _unicodeSize(string)
1291
+ : _asciiSize(string);
1292
+ }
1293
+
1294
+ var _stringSize = stringSize;
1295
+
1296
+ /** `Object#toString` result references. */
1297
+ var mapTag = '[object Map]',
1298
+ setTag = '[object Set]';
1299
+
1300
+ /**
1301
+ * Gets the size of `collection` by returning its length for array-like
1302
+ * values or the number of own enumerable string keyed properties for objects.
1303
+ *
1304
+ * @static
1305
+ * @memberOf _
1306
+ * @since 0.1.0
1307
+ * @category Collection
1308
+ * @param {Array|Object|string} collection The collection to inspect.
1309
+ * @returns {number} Returns the collection size.
1310
+ * @example
1311
+ *
1312
+ * _.size([1, 2, 3]);
1313
+ * // => 3
1314
+ *
1315
+ * _.size({ 'a': 1, 'b': 2 });
1316
+ * // => 2
1317
+ *
1318
+ * _.size('pebbles');
1319
+ * // => 7
1320
+ */
1321
+ function size(collection) {
1322
+ if (collection == null) {
1323
+ return 0;
1324
+ }
1325
+ if (isArrayLike_1(collection)) {
1326
+ return isString_1(collection) ? _stringSize(collection) : collection.length;
1327
+ }
1328
+ var tag = _getTag(collection);
1329
+ if (tag == mapTag || tag == setTag) {
1330
+ return collection.size;
1331
+ }
1332
+ return _baseKeys(collection).length;
1333
+ }
1334
+
1335
+ var size_1 = size;
1336
+
1337
+ /**
1338
+ * lifecycle
1339
+ * 1) @event beforesorting - sorting just started, nothing happened yet
1340
+ * 2) @metod updateColumnSorting - column sorting icon applied to grid and column get updated, data still untiuched
1341
+ * 3) @event beforesortingapply - before we applied sorting data to data source, you can prevent data apply from here
1342
+ * 4) @event afterSortingApply - sorting applied, just finished event
1343
+ *
1344
+ * If you prevent event it'll not reach farther steps
1345
+ */
1346
+ class SortingPlugin extends BasePlugin {
1347
+ constructor(revogrid) {
1348
+ super(revogrid);
1349
+ this.revogrid = revogrid;
1350
+ this.sorting = null;
1351
+ this.sortingFunc = null;
1352
+ const beforesourceset = ({ detail }) => {
1353
+ if (this.hasSorting) {
1354
+ // is sorting allowed
1355
+ const event = this.emit('beforesourcesortingapply');
1356
+ // sorting prevented
1357
+ if (event.defaultPrevented) {
1358
+ return;
1359
+ }
1360
+ }
1361
+ const data = this.setData(detail.source, detail.type);
1362
+ if (data) {
1363
+ detail.source = data;
1364
+ }
1365
+ };
1366
+ const aftercolumnsset = async ({ detail: { order } }) => {
1367
+ const columns = await this.revogrid.getColumns();
1368
+ const sortingFunc = {};
1369
+ for (let prop in order) {
1370
+ const column = ColumnDataProvider.getColumnByProp(columns, prop);
1371
+ const cmp = (column === null || column === void 0 ? void 0 : column.cellCompare) || this.defaultCellCompare;
1372
+ sortingFunc[prop] = order[prop] == 'desc' ? this.descCellCompare(cmp) : cmp;
1373
+ }
1374
+ this.sort(order, sortingFunc);
1375
+ };
1376
+ const headerclick = async (e) => {
1377
+ var _a, _b;
1378
+ if (e.defaultPrevented) {
1379
+ return;
1380
+ }
1381
+ if (!e.detail.column.sortable) {
1382
+ return;
1383
+ }
1384
+ this.headerclick(e.detail.column, e.detail.index, (_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.originalEvent) === null || _b === void 0 ? void 0 : _b.shiftKey);
1385
+ };
1386
+ this.addEventListener('beforesourceset', beforesourceset);
1387
+ this.addEventListener('aftercolumnsset', aftercolumnsset);
1388
+ this.addEventListener('initialHeaderClick', headerclick);
1389
+ }
1390
+ get hasSorting() {
1391
+ return !!this.sorting;
1392
+ }
1393
+ async headerclick(column, index, additive) {
1394
+ let order = this.getNextOrder(column.order);
1395
+ const beforeEvent = this.emit('beforesorting', { column, order, additive });
1396
+ if (beforeEvent.defaultPrevented) {
1397
+ return;
1398
+ }
1399
+ order = beforeEvent.detail.order;
1400
+ const newCol = await this.revogrid.updateColumnSorting(beforeEvent.detail.column, index, order, additive);
1401
+ // apply sort data
1402
+ const beforeApplyEvent = this.emit('beforesortingapply', { column: newCol, order, additive });
1403
+ if (beforeApplyEvent.defaultPrevented) {
1404
+ return;
1405
+ }
1406
+ order = beforeApplyEvent.detail.order;
1407
+ const cellCmp = (column === null || column === void 0 ? void 0 : column.cellCompare) || this.defaultCellCompare;
1408
+ const cmp = order == 'asc' ? cellCmp : order == 'desc' ? this.descCellCompare(cellCmp) : undefined;
1409
+ if (additive && this.sorting) {
1410
+ const sorting = {};
1411
+ const sortingFunc = {};
1412
+ Object.assign(sorting, this.sorting);
1413
+ Object.assign(sortingFunc, this.sortingFunc);
1414
+ if (column.prop in sorting && size_1(sorting) > 1 && order === undefined) {
1415
+ delete sorting[column.prop];
1416
+ delete sortingFunc[column.prop];
1417
+ }
1418
+ else {
1419
+ sorting[column.prop] = order;
1420
+ sortingFunc[column.prop] = cmp;
1421
+ }
1422
+ this.sort(sorting, sortingFunc);
1423
+ }
1424
+ else {
1425
+ this.sort({ [column.prop]: order }, { [column.prop]: cmp });
1426
+ }
1427
+ }
1428
+ setData(data, type) {
1429
+ // sorting available for rgRow type only
1430
+ if (type === 'rgRow' && this.sortingFunc) {
1431
+ return this.sortItems(data, this.sortingFunc);
1432
+ }
1433
+ }
1434
+ /**
1435
+ * Sorting apply, available for rgRow type only
1436
+ * @param sorting - per column sorting
1437
+ * @param data - this.stores['rgRow'].store.get('source')
1438
+ */
1439
+ async sort(sorting, sortingFunc) {
1440
+ if (!size_1(sorting)) {
1441
+ this.sorting = null;
1442
+ this.sortingFunc = null;
1443
+ return;
1444
+ }
1445
+ this.sorting = sorting;
1446
+ this.sortingFunc = sortingFunc;
1447
+ const store = await this.revogrid.getSourceStore();
1448
+ const source = store.get('source');
1449
+ const proxyItems = this.sortIndexByItems([...store.get('proxyItems')], source, this.sortingFunc);
1450
+ setStore(store, {
1451
+ proxyItems,
1452
+ source: [...source],
1453
+ });
1454
+ this.emit('afterSortingApply');
1455
+ }
1456
+ defaultCellCompare(prop, a, b) {
1457
+ var _a, _b;
1458
+ const av = (_a = a[prop]) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
1459
+ const bv = (_b = b[prop]) === null || _b === void 0 ? void 0 : _b.toString().toLowerCase();
1460
+ return av == bv ? 0 : av > bv ? 1 : -1;
1461
+ }
1462
+ descCellCompare(cmp) {
1463
+ return (prop, a, b) => { return -1 * cmp(prop, a, b); };
1464
+ }
1465
+ sortIndexByItems(indexes, source, sortingFunc) {
1466
+ // TODO - is there a situation where multiple kvps in the `sorting` object would cause this to break?
1467
+ for (let prop in sortingFunc) {
1468
+ if (typeof sortingFunc[prop] === 'undefined') {
1469
+ // Unsort indexes
1470
+ return [...Array(indexes.length).keys()];
1471
+ }
1472
+ }
1473
+ return indexes.sort((a, b) => {
1474
+ let sorted = 0;
1475
+ for (let prop in sortingFunc) {
1476
+ const cmp = sortingFunc[prop];
1477
+ const itemA = source[a];
1478
+ const itemB = source[b];
1479
+ sorted = cmp(prop, itemA, itemB);
1480
+ if (sorted) {
1481
+ break;
1482
+ }
1483
+ }
1484
+ return sorted;
1485
+ });
1486
+ }
1487
+ sortItems(source, sortingFunc) {
1488
+ return source.sort((a, b) => {
1489
+ let sorted = 0;
1490
+ for (let prop in sortingFunc) {
1491
+ const cmp = sortingFunc[prop];
1492
+ if (!cmp) {
1493
+ continue;
1494
+ }
1495
+ sorted = cmp(prop, a, b);
1496
+ if (sorted) {
1497
+ break;
1498
+ }
1499
+ }
1500
+ return sorted;
1501
+ });
1502
+ }
1503
+ getNextOrder(currentOrder) {
1504
+ switch (currentOrder) {
1505
+ case undefined:
1506
+ return 'asc';
1507
+ case 'asc':
1508
+ return 'desc';
1509
+ case 'desc':
1510
+ return undefined;
1511
+ }
1512
+ }
1513
+ }
1514
+
1515
+ /**
1516
+ * The base implementation of `_.clamp` which doesn't coerce arguments.
1517
+ *
1518
+ * @private
1519
+ * @param {number} number The number to clamp.
1520
+ * @param {number} [lower] The lower bound.
1521
+ * @param {number} upper The upper bound.
1522
+ * @returns {number} Returns the clamped number.
1523
+ */
1524
+ function baseClamp(number, lower, upper) {
1525
+ if (number === number) {
1526
+ if (upper !== undefined) {
1527
+ number = number <= upper ? number : upper;
1528
+ }
1529
+ if (lower !== undefined) {
1530
+ number = number >= lower ? number : lower;
1531
+ }
1532
+ }
1533
+ return number;
1534
+ }
1535
+
1536
+ var _baseClamp = baseClamp;
1537
+
1538
+ /** Used as references for the maximum length and index of an array. */
1539
+ var MAX_ARRAY_LENGTH = 4294967295;
1540
+
1541
+ /**
1542
+ * Converts `value` to an integer suitable for use as the length of an
1543
+ * array-like object.
1544
+ *
1545
+ * **Note:** This method is based on
1546
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1547
+ *
1548
+ * @static
1549
+ * @memberOf _
1550
+ * @since 4.0.0
1551
+ * @category Lang
1552
+ * @param {*} value The value to convert.
1553
+ * @returns {number} Returns the converted integer.
1554
+ * @example
1555
+ *
1556
+ * _.toLength(3.2);
1557
+ * // => 3
1558
+ *
1559
+ * _.toLength(Number.MIN_VALUE);
1560
+ * // => 0
1561
+ *
1562
+ * _.toLength(Infinity);
1563
+ * // => 4294967295
1564
+ *
1565
+ * _.toLength('3.2');
1566
+ * // => 3
1567
+ */
1568
+ function toLength(value) {
1569
+ return value ? _baseClamp(toInteger_1(value), 0, MAX_ARRAY_LENGTH) : 0;
1570
+ }
1571
+
1572
+ var toLength_1 = toLength;
1573
+
1574
+ /**
1575
+ * The base implementation of `_.fill` without an iteratee call guard.
1576
+ *
1577
+ * @private
1578
+ * @param {Array} array The array to fill.
1579
+ * @param {*} value The value to fill `array` with.
1580
+ * @param {number} [start=0] The start position.
1581
+ * @param {number} [end=array.length] The end position.
1582
+ * @returns {Array} Returns `array`.
1583
+ */
1584
+ function baseFill(array, value, start, end) {
1585
+ var length = array.length;
1586
+
1587
+ start = toInteger_1(start);
1588
+ if (start < 0) {
1589
+ start = -start > length ? 0 : (length + start);
1590
+ }
1591
+ end = (end === undefined || end > length) ? length : toInteger_1(end);
1592
+ if (end < 0) {
1593
+ end += length;
1594
+ }
1595
+ end = start > end ? 0 : toLength_1(end);
1596
+ while (start < end) {
1597
+ array[start++] = value;
1598
+ }
1599
+ return array;
1600
+ }
1601
+
1602
+ var _baseFill = baseFill;
1603
+
1604
+ /**
1605
+ * Fills elements of `array` with `value` from `start` up to, but not
1606
+ * including, `end`.
1607
+ *
1608
+ * **Note:** This method mutates `array`.
1609
+ *
1610
+ * @static
1611
+ * @memberOf _
1612
+ * @since 3.2.0
1613
+ * @category Array
1614
+ * @param {Array} array The array to fill.
1615
+ * @param {*} value The value to fill `array` with.
1616
+ * @param {number} [start=0] The start position.
1617
+ * @param {number} [end=array.length] The end position.
1618
+ * @returns {Array} Returns `array`.
1619
+ * @example
1620
+ *
1621
+ * var array = [1, 2, 3];
1622
+ *
1623
+ * _.fill(array, 'a');
1624
+ * console.log(array);
1625
+ * // => ['a', 'a', 'a']
1626
+ *
1627
+ * _.fill(Array(3), 2);
1628
+ * // => [2, 2, 2]
1629
+ *
1630
+ * _.fill([4, 6, 8, 10], '*', 1, 3);
1631
+ * // => [4, '*', '*', 10]
1632
+ */
1633
+ function fill(array, value, start, end) {
1634
+ var length = array == null ? 0 : array.length;
1635
+ if (!length) {
1636
+ return [];
1637
+ }
1638
+ if (start && typeof start != 'number' && _isIterateeCall(array, value, start)) {
1639
+ start = 0;
1640
+ end = length;
1641
+ }
1642
+ return _baseFill(array, value, start, end);
1643
+ }
1644
+
1645
+ var fill_1 = fill;
1646
+
1647
+ const INITIAL = {
1648
+ mime: 'text/csv',
1649
+ fileKind: 'csv',
1650
+ // BOM signature
1651
+ bom: true,
1652
+ columnDelimiter: ',',
1653
+ rowDelimiter: '\r\n',
1654
+ encoding: '',
1655
+ };
1656
+ // The ASCII character code 13 is called a Carriage Return or CR.
1657
+ const CARRIAGE_RETURN = String.fromCharCode(13);
1658
+ // Chr(13) followed by a Chr(10) that compose a proper CRLF.
1659
+ const LINE_FEED = String.fromCharCode(10);
1660
+ const DOUBLE_QT = String.fromCharCode(34);
1661
+ const NO_BREAK_SPACE = String.fromCharCode(0xfeff);
1662
+ const escapeRegex = new RegExp('"', 'g');
1663
+ class ExportCsv {
1664
+ constructor(options = {}) {
1665
+ this.options = Object.assign(Object.assign({}, INITIAL), options);
1666
+ }
1667
+ doExport({ data, headers, props }) {
1668
+ let result = this.options.bom ? NO_BREAK_SPACE : '';
1669
+ // any header
1670
+ if ((headers === null || headers === void 0 ? void 0 : headers.length) > 0) {
1671
+ headers.forEach(header => {
1672
+ // ignore empty
1673
+ if (!header.length) {
1674
+ return;
1675
+ }
1676
+ result += this.prepareHeader(header, this.options.columnDelimiter);
1677
+ result += this.options.rowDelimiter;
1678
+ });
1679
+ }
1680
+ data.forEach((rgRow, index) => {
1681
+ if (index > 0) {
1682
+ result += this.options.rowDelimiter;
1683
+ }
1684
+ // support grouping
1685
+ if (isGrouping(rgRow)) {
1686
+ result += this.parseCell(getGroupingName(rgRow), this.options.columnDelimiter);
1687
+ return;
1688
+ }
1689
+ result += props.map(p => this.parseCell(rgRow[p], this.options.columnDelimiter)).join(this.options.columnDelimiter);
1690
+ });
1691
+ return result;
1692
+ }
1693
+ prepareHeader(columnHeaders, columnDelimiter) {
1694
+ let result = '';
1695
+ const newColumnHeaders = columnHeaders.map(v => this.parseCell(v, columnDelimiter, true));
1696
+ result += newColumnHeaders.join(columnDelimiter);
1697
+ return result;
1698
+ }
1699
+ parseCell(value, columnDelimiter, force = false) {
1700
+ let escape = value;
1701
+ if (typeof value !== 'string') {
1702
+ escape = JSON.stringify(value);
1703
+ }
1704
+ const toEscape = [CARRIAGE_RETURN, DOUBLE_QT, LINE_FEED, columnDelimiter];
1705
+ if (typeof escape === 'undefined') {
1706
+ return '';
1707
+ }
1708
+ if (escape !== '' && (force || toEscape.some(i => escape.indexOf(i) >= 0))) {
1709
+ return `"${escape.replace(escapeRegex, '""')}"`;
1710
+ }
1711
+ return escape;
1712
+ }
1713
+ }
1714
+
1715
+ var ExportTypes;
1716
+ (function (ExportTypes) {
1717
+ ExportTypes["csv"] = "csv";
1718
+ })(ExportTypes || (ExportTypes = {}));
1719
+ class ExportFilePlugin extends BasePlugin {
1720
+ /** Exports string */
1721
+ async exportString(options = {}, t = ExportTypes.csv) {
1722
+ const data = await this.beforeexport();
1723
+ if (!data) {
1724
+ return null;
1725
+ }
1726
+ return this.formatter(t, options).doExport(data);
1727
+ }
1728
+ /** Exports Blob */
1729
+ async exportBlob(options = {}, t = ExportTypes.csv) {
1730
+ return await this.getBlob(this.formatter(t, options));
1731
+ }
1732
+ /** Export file */
1733
+ async exportFile(options = {}, t = ExportTypes.csv) {
1734
+ const formatter = this.formatter(t, options);
1735
+ const blob = await this.getBlob(formatter);
1736
+ // url
1737
+ const URL = window.URL || window.webkitURL;
1738
+ const a = document.createElement('a');
1739
+ const { filename, fileKind } = formatter.options;
1740
+ const name = `${filename}.${fileKind}`;
1741
+ const url = URL.createObjectURL(blob);
1742
+ a.style.display = 'none';
1743
+ a.setAttribute('href', url);
1744
+ a.setAttribute('download', name);
1745
+ this.revogrid.appendChild(a);
1746
+ a.dispatchEvent(new MouseEvent('click'));
1747
+ this.revogrid.removeChild(a);
1748
+ // delay for revoke, correct for some browsers
1749
+ await timeout(120);
1750
+ URL.revokeObjectURL(url);
1751
+ }
1752
+ /** Blob object */
1753
+ async getBlob(formatter) {
1754
+ const type = `${formatter.options.mime};charset=${formatter.options.encoding}`;
1755
+ if (typeof Blob !== 'undefined') {
1756
+ const data = await this.beforeexport();
1757
+ if (!data) {
1758
+ return null;
1759
+ }
1760
+ return new Blob([formatter.doExport(data)], { type });
1761
+ }
1762
+ return null;
1763
+ }
1764
+ // before event
1765
+ async beforeexport() {
1766
+ let data = await this.getData();
1767
+ const event = this.emit('beforeexport', { data });
1768
+ if (event.defaultPrevented) {
1769
+ return null;
1770
+ }
1771
+ return event.detail.data;
1772
+ }
1773
+ async getData() {
1774
+ const data = await this.getSource();
1775
+ const colSource = [];
1776
+ const colPromises = [];
1777
+ columnTypes.forEach((t, i) => {
1778
+ colPromises.push(this.getColPerSource(t).then(s => (colSource[i] = s)));
1779
+ });
1780
+ await Promise.all(colPromises);
1781
+ const columns = {
1782
+ headers: [],
1783
+ props: [],
1784
+ };
1785
+ for (let source of colSource) {
1786
+ source.headers.forEach((h, i) => {
1787
+ if (!columns.headers[i]) {
1788
+ columns.headers[i] = [];
1789
+ }
1790
+ columns.headers[i].push(...h);
1791
+ });
1792
+ columns.props.push(...source.props);
1793
+ }
1794
+ return Object.assign({ data }, columns);
1795
+ }
1796
+ async getColPerSource(t) {
1797
+ const store = await this.revogrid.getColumnStore(t);
1798
+ const source = store.get('source');
1799
+ const virtualIndexes = store.get('items');
1800
+ const depth = store.get('groupingDepth');
1801
+ const groups = store.get('groups');
1802
+ const colNames = [];
1803
+ const colProps = [];
1804
+ const visibleItems = virtualIndexes.reduce((r, v, virtualIndex) => {
1805
+ const prop = source[v].prop;
1806
+ colNames.push(source[v].name || '');
1807
+ colProps.push(prop);
1808
+ r[prop] = virtualIndex;
1809
+ return r;
1810
+ }, {});
1811
+ const rows = this.getGroupHeaders(depth, groups, virtualIndexes, visibleItems);
1812
+ rows.push(colNames);
1813
+ return {
1814
+ headers: rows,
1815
+ props: colProps,
1816
+ };
1817
+ }
1818
+ getGroupHeaders(depth, groups, items, visibleItems) {
1819
+ const rows = [];
1820
+ const template = fill_1(new Array(items.length), '');
1821
+ for (let d = 0; d < depth; d++) {
1822
+ const rgRow = [...template];
1823
+ rows.push(rgRow);
1824
+ if (!groups[d]) {
1825
+ continue;
1826
+ }
1827
+ const levelGroups = groups[d];
1828
+ // add names of groups
1829
+ levelGroups.forEach((group) => {
1830
+ const minIndex = this.findGroupStartIndex(group.ids, visibleItems);
1831
+ if (typeof minIndex === 'number') {
1832
+ rgRow[minIndex] = group.name;
1833
+ }
1834
+ });
1835
+ }
1836
+ return rows;
1837
+ }
1838
+ findGroupStartIndex(ids, visibleItems) {
1839
+ let min;
1840
+ ids.forEach(id => {
1841
+ const current = visibleItems[id];
1842
+ if (typeof current === 'number') {
1843
+ if (typeof min !== 'number' || min > current) {
1844
+ min = current;
1845
+ }
1846
+ }
1847
+ });
1848
+ return min;
1849
+ }
1850
+ async getSource() {
1851
+ const data = [];
1852
+ const promisesData = [];
1853
+ rowTypes.forEach(t => {
1854
+ const dataPart = [];
1855
+ data.push(dataPart);
1856
+ const promise = this.revogrid.getVisibleSource(t).then((d) => dataPart.push(...d));
1857
+ promisesData.push(promise);
1858
+ });
1859
+ await Promise.all(promisesData);
1860
+ return data.reduce((r, v) => {
1861
+ r.push(...v);
1862
+ return r;
1863
+ }, []);
1864
+ }
1865
+ // get correct class for future multiple types support
1866
+ formatter(type, options = {}) {
1867
+ switch (type) {
1868
+ case ExportTypes.csv:
1869
+ return new ExportCsv(options);
1870
+ default:
1871
+ throw new Error('Unknown format');
1872
+ }
1873
+ }
1874
+ }
1875
+
1876
+ // provide collapse data
1877
+ function doCollapse(pIndex, source) {
1878
+ const model = source[pIndex];
1879
+ const currentId = model[PSEUDO_GROUP_ITEM_ID];
1880
+ const trimmed = {};
1881
+ let i = pIndex + 1;
1882
+ const total = source.length;
1883
+ while (i < total) {
1884
+ const currentModel = source[i];
1885
+ if (isGrouping(currentModel)) {
1886
+ if (currentId !== currentModel[PSEUDO_GROUP_ITEM_ID]) {
1887
+ break;
1888
+ }
1889
+ else {
1890
+ currentModel[GROUP_EXPANDED] = false;
1891
+ }
1892
+ }
1893
+ trimmed[i++] = true;
1894
+ }
1895
+ model[GROUP_EXPANDED] = false;
1896
+ return { trimmed };
1897
+ }
1898
+ /**
1899
+ *
1900
+ * @param pIndex - physical index
1901
+ * @param vIndex - virtual index, need to update item collection
1902
+ * @param source - data source
1903
+ * @param rowItemsIndexes - rgRow indexes
1904
+ */
1905
+ function doExpand(vIndex, source, rowItemsIndexes) {
1906
+ const physicalIndex = rowItemsIndexes[vIndex];
1907
+ const model = source[physicalIndex];
1908
+ const currentGroup = getParsedGroup(model[PSEUDO_GROUP_ITEM_ID]);
1909
+ const trimmed = {};
1910
+ // no group found
1911
+ if (!currentGroup) {
1912
+ return { trimmed };
1913
+ }
1914
+ const groupItems = [];
1915
+ model[GROUP_EXPANDED] = true;
1916
+ let i = physicalIndex + 1;
1917
+ const total = source.length;
1918
+ let groupLevelOnly = 0;
1919
+ // go through all rows
1920
+ while (i < total) {
1921
+ const currentModel = source[i];
1922
+ const isGroup = isGrouping(currentModel);
1923
+ // group found
1924
+ if (isGroup) {
1925
+ if (!isSameGroup(currentGroup, model, currentModel)) {
1926
+ break;
1927
+ }
1928
+ else if (!groupLevelOnly) {
1929
+ // if get group first it's group only level
1930
+ groupLevelOnly = currentModel[GROUP_DEPTH];
1931
+ }
1932
+ }
1933
+ // level 0 or same depth
1934
+ if (!groupLevelOnly || (isGroup && groupLevelOnly === currentModel[GROUP_DEPTH])) {
1935
+ trimmed[i] = false;
1936
+ groupItems.push(i);
1937
+ }
1938
+ i++;
1939
+ }
1940
+ const result = {
1941
+ trimmed,
1942
+ };
1943
+ if (groupItems.length) {
1944
+ const items = [...rowItemsIndexes];
1945
+ items.splice(vIndex + 1, 0, ...groupItems);
1946
+ result.items = items;
1947
+ }
1948
+ return result;
1949
+ }
1950
+
1951
+ const TRIMMED_GROUPING = 'grouping';
1952
+ /**
1953
+ * Prepare trimming updated indexes for grouping
1954
+ * @param initiallyTrimed
1955
+ * @param firstLevelMap
1956
+ * @param secondLevelMap
1957
+ */
1958
+ function processDoubleConversionTrimmed(initiallyTrimed, firstLevelMap, secondLevelMap) {
1959
+ const trimemedOptionsToUpgrade = {};
1960
+ /**
1961
+ * go through all groups except grouping
1962
+ */
1963
+ for (let type in initiallyTrimed) {
1964
+ if (type === TRIMMED_GROUPING) {
1965
+ continue;
1966
+ }
1967
+ const items = initiallyTrimed[type];
1968
+ const newItems = {};
1969
+ for (let initialIndex in items) {
1970
+ /**
1971
+ * if item exists we find it in collection
1972
+ * we support 2 level of conversions
1973
+ */
1974
+ let newConversionIndex = firstLevelMap[initialIndex];
1975
+ if (secondLevelMap) {
1976
+ newConversionIndex = secondLevelMap[newConversionIndex];
1977
+ }
1978
+ /**
1979
+ * if item was trimmed previously
1980
+ * trimming makes sense to apply
1981
+ */
1982
+ if (items[initialIndex]) {
1983
+ newItems[newConversionIndex] = true;
1984
+ /**
1985
+ * If changes present apply changes to new source
1986
+ */
1987
+ if (newConversionIndex !== parseInt(initialIndex, 10)) {
1988
+ trimemedOptionsToUpgrade[type] = newItems;
1989
+ }
1990
+ }
1991
+ }
1992
+ }
1993
+ return trimemedOptionsToUpgrade;
1994
+ }
1995
+ function filterOutEmptyGroups(allTrimmedGroups, childrenByGroup = {}) {
1996
+ const trimmedGroup = {};
1997
+ const allTrimmed = gatherTrimmedItems(allTrimmedGroups);
1998
+ // find is groups are filled
1999
+ for (let groupIndex in childrenByGroup) {
2000
+ const hasChidlren = childrenByGroup[groupIndex].filter(childIndex => !allTrimmed[childIndex]).length > 0;
2001
+ if (!hasChidlren) {
2002
+ trimmedGroup[groupIndex] = true;
2003
+ }
2004
+ }
2005
+ return trimmedGroup;
2006
+ }
2007
+
2008
+ class GroupingRowPlugin extends BasePlugin {
2009
+ constructor(revogrid, providers) {
2010
+ super(revogrid);
2011
+ this.revogrid = revogrid;
2012
+ this.providers = providers;
2013
+ }
2014
+ get hasProps() {
2015
+ var _a, _b, _c;
2016
+ return ((_a = this.options) === null || _a === void 0 ? void 0 : _a.props) && ((_c = (_b = this.options) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.length);
2017
+ }
2018
+ get store() {
2019
+ return this.providers.dataProvider.stores[GROUPING_ROW_TYPE].store;
2020
+ }
2021
+ // proxy for items get
2022
+ get rowItems() {
2023
+ return this.store.get('items');
2024
+ }
2025
+ get trimmed() {
2026
+ return this.store.get('trimmed');
2027
+ }
2028
+ // befoce cell focus
2029
+ onFocus(e) {
2030
+ if (isGrouping(e.detail.model)) {
2031
+ e.preventDefault();
2032
+ }
2033
+ }
2034
+ // expand event triggered
2035
+ onExpand({ virtualIndex }) {
2036
+ const { source } = this.getSource();
2037
+ let newTrimmed = this.trimmed[TRIMMED_GROUPING];
2038
+ let i = getPhysical(this.store, virtualIndex);
2039
+ const model = source[i];
2040
+ const prevExpanded = model[GROUP_EXPANDED];
2041
+ if (!prevExpanded) {
2042
+ const { trimmed, items } = doExpand(virtualIndex, source, this.rowItems);
2043
+ newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
2044
+ if (items) {
2045
+ setItems(this.store, items);
2046
+ }
2047
+ }
2048
+ else {
2049
+ const { trimmed } = doCollapse(i, source);
2050
+ newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
2051
+ this.revogrid.clearFocus();
2052
+ }
2053
+ this.store.set('source', source);
2054
+ this.revogrid.addTrimmed(newTrimmed, TRIMMED_GROUPING);
2055
+ }
2056
+ // get source based on proxy item collection to preserve rgRow order
2057
+ getSource(withoutGrouping = false) {
2058
+ const source = this.store.get('source');
2059
+ const items = this.store.get('proxyItems');
2060
+ let index = 0;
2061
+ // order important here, expected parent is first, then others
2062
+ return items.reduce((result, i) => {
2063
+ const model = source[i];
2064
+ if (!withoutGrouping) {
2065
+ result.source.push(model);
2066
+ return result;
2067
+ }
2068
+ // grouping filter
2069
+ if (!isGrouping(model)) {
2070
+ result.source.push(model);
2071
+ result.oldNewIndexes[i] = index;
2072
+ index++;
2073
+ }
2074
+ else {
2075
+ if (model[GROUP_EXPANDED]) {
2076
+ result.prevExpanded[model[PSEUDO_GROUP_ITEM_VALUE]] = true;
2077
+ }
2078
+ }
2079
+ return result;
2080
+ }, {
2081
+ source: [],
2082
+ prevExpanded: {},
2083
+ oldNewIndexes: {},
2084
+ });
2085
+ }
2086
+ setColumnGrouping(cols) {
2087
+ // if 0 column as holder
2088
+ if (cols === null || cols === void 0 ? void 0 : cols.length) {
2089
+ cols[0][PSEUDO_GROUP_COLUMN] = true;
2090
+ return true;
2091
+ }
2092
+ return false;
2093
+ }
2094
+ setColumns({ columns }) {
2095
+ for (let type of columnTypes) {
2096
+ if (this.setColumnGrouping(columns[type])) {
2097
+ break;
2098
+ }
2099
+ }
2100
+ }
2101
+ // evaluate drag between groups
2102
+ onDrag(e) {
2103
+ const { from, to } = e.detail;
2104
+ const isDown = to - from >= 0;
2105
+ const { source } = this.getSource();
2106
+ const items = this.rowItems;
2107
+ let i = isDown ? from : to;
2108
+ const end = isDown ? to : from;
2109
+ for (; i < end; i++) {
2110
+ const model = source[items[i]];
2111
+ const isGroup = isGrouping(model);
2112
+ if (isGroup) {
2113
+ e.preventDefault();
2114
+ return;
2115
+ }
2116
+ }
2117
+ }
2118
+ beforeTrimmedApply(trimmed, type) {
2119
+ /** Before filter apply remove grouping filtering */
2120
+ if (type === FILTER_TRIMMED_TYPE) {
2121
+ const source = this.store.get('source');
2122
+ for (let index in trimmed) {
2123
+ if (trimmed[index] && isGrouping(source[index])) {
2124
+ trimmed[index] = false;
2125
+ }
2126
+ }
2127
+ }
2128
+ }
2129
+ // subscribe to grid events to process them accordingly
2130
+ subscribe() {
2131
+ /** if grouping present and new data source arrived */
2132
+ this.addEventListener('beforesourceset', ({ detail }) => this.onDataSet(detail));
2133
+ this.addEventListener('beforecolumnsset', ({ detail }) => this.setColumns(detail));
2134
+ /**
2135
+ * filter applied need to clear grouping and apply again
2136
+ * based on new results can be new grouping
2137
+ */
2138
+ this.addEventListener('beforetrimmed', ({ detail: { trimmed, trimmedType } }) => this.beforeTrimmedApply(trimmed, trimmedType));
2139
+ /**
2140
+ * sorting applied need to clear grouping and apply again
2141
+ * based on new results whole grouping order will changed
2142
+ */
2143
+ this.addEventListener('afterSortingApply', () => this.doSourceUpdate());
2144
+ /**
2145
+ * Apply logic for focus inside of grouping
2146
+ * We can't focus on grouping rows, navigation only inside of groups for now
2147
+ */
2148
+ this.addEventListener('beforecellfocus', e => this.onFocus(e));
2149
+ /**
2150
+ * Prevent rgRow drag outside the group
2151
+ */
2152
+ this.addEventListener('roworderchanged', e => this.onDrag(e));
2153
+ /**
2154
+ * When grouping expand icon was clicked
2155
+ */
2156
+ this.addEventListener(GROUP_EXPAND_EVENT, ({ detail }) => this.onExpand(detail));
2157
+ }
2158
+ /**
2159
+ * Starts global source update with group clearing and applying new one
2160
+ * Initiated when need to reapply grouping
2161
+ */
2162
+ doSourceUpdate(options) {
2163
+ if (!this.hasProps) {
2164
+ return;
2165
+ }
2166
+ /**
2167
+ * Get source without grouping
2168
+ * @param newOldIndexMap - provides us mapping with new indexes vs old indexes, we would use it for trimmed mapping
2169
+ */
2170
+ const { source, prevExpanded, oldNewIndexes } = this.getSource(true);
2171
+ /**
2172
+ * Group again
2173
+ * @param oldNewIndexMap - provides us mapping with new indexes vs old indexes
2174
+ */
2175
+ const { sourceWithGroups, depth, trimmed, oldNewIndexMap, childrenByGroup } = gatherGrouping(source,
2176
+ // filter
2177
+ item => { var _a; return (_a = this.options) === null || _a === void 0 ? void 0 : _a.props.map(key => item[key]); }, Object.assign({ prevExpanded }, options));
2178
+ // setup source
2179
+ this.providers.dataProvider.setData(sourceWithGroups, GROUPING_ROW_TYPE, { depth }, true);
2180
+ this.updateTrimmed(trimmed, childrenByGroup, oldNewIndexes, oldNewIndexMap);
2181
+ }
2182
+ /**
2183
+ * Apply grouping on data set
2184
+ * Clear grouping from source
2185
+ * If source came from other plugin
2186
+ */
2187
+ onDataSet(data) {
2188
+ if (!this.hasProps || !(data === null || data === void 0 ? void 0 : data.source) || !data.source.length) {
2189
+ return;
2190
+ }
2191
+ const source = data.source.filter(s => !isGrouping(s));
2192
+ const expanded = this.revogrid.grouping || {};
2193
+ const { sourceWithGroups, depth, trimmed, oldNewIndexMap, childrenByGroup } = gatherGrouping(source,
2194
+ // filter
2195
+ item => { var _a; return (_a = this.options) === null || _a === void 0 ? void 0 : _a.props.map(key => item[key]); }, Object.assign({}, (expanded || {})));
2196
+ data.source = sourceWithGroups;
2197
+ this.providers.dataProvider.setGrouping({ depth });
2198
+ this.updateTrimmed(trimmed, childrenByGroup, oldNewIndexMap);
2199
+ }
2200
+ // apply grouping
2201
+ setGrouping(options) {
2202
+ // unsubscribe from all events when group applied
2203
+ this.clearSubscriptions();
2204
+ this.options = options;
2205
+ // clear props, no grouping exists
2206
+ if (!options.props || !Object.keys(options.props).length) {
2207
+ this.clearGrouping();
2208
+ return;
2209
+ }
2210
+ // props exist and source inited
2211
+ const { source } = this.getSource();
2212
+ if (source.length) {
2213
+ this.doSourceUpdate(Object.assign({}, options));
2214
+ }
2215
+ // props exist and columns inited
2216
+ for (let t of columnTypes) {
2217
+ if (this.setColumnGrouping(this.providers.columnProvider.getColumns(t))) {
2218
+ this.providers.columnProvider.refreshByType(t);
2219
+ break;
2220
+ }
2221
+ }
2222
+ // if has any grouping subscribe to events again
2223
+ this.subscribe();
2224
+ }
2225
+ // clear grouping
2226
+ clearGrouping() {
2227
+ // clear columns
2228
+ columnTypes.forEach(t => {
2229
+ const cols = this.providers.columnProvider.getColumns(t);
2230
+ let deleted = false;
2231
+ cols.forEach(c => {
2232
+ if (isGroupingColumn(c)) {
2233
+ delete c[PSEUDO_GROUP_COLUMN];
2234
+ deleted = true;
2235
+ }
2236
+ });
2237
+ // if column store had grouping clear and refresh
2238
+ if (deleted) {
2239
+ this.providers.columnProvider.refreshByType(t);
2240
+ }
2241
+ });
2242
+ // clear rows
2243
+ const { source, oldNewIndexes } = this.getSource(true);
2244
+ this.providers.dataProvider.setData(source, GROUPING_ROW_TYPE, undefined, true);
2245
+ this.updateTrimmed(undefined, undefined, oldNewIndexes);
2246
+ }
2247
+ updateTrimmed(trimmedGroup = {}, _childrenByGroup = {}, firstLevelMap, secondLevelMap) {
2248
+ // map previously trimmed data
2249
+ const trimemedOptionsToUpgrade = processDoubleConversionTrimmed(this.trimmed, firstLevelMap, secondLevelMap);
2250
+ for (let type in trimemedOptionsToUpgrade) {
2251
+ this.revogrid.addTrimmed(trimemedOptionsToUpgrade[type], type);
2252
+ }
2253
+ // const emptyGroups = this.filterOutEmptyGroups(trimemedOptionsToUpgrade, childrenByGroup);
2254
+ // setup trimmed data for grouping
2255
+ this.revogrid.addTrimmed(Object.assign({}, trimmedGroup), TRIMMED_GROUPING);
2256
+ }
2257
+ }
2258
+
2259
+ /**
2260
+ * Draw drag
2261
+ */
2262
+ class OrdererService {
2263
+ constructor() {
2264
+ this.parentY = 0;
2265
+ }
2266
+ start(parent, { pos, text, event }) {
2267
+ var _a;
2268
+ const { top } = parent.getBoundingClientRect();
2269
+ this.parentY = top;
2270
+ if (this.text) {
2271
+ this.text.innerText = text;
2272
+ }
2273
+ this.move(pos);
2274
+ this.moveTip({ x: event.x, y: event.y });
2275
+ (_a = this.el) === null || _a === void 0 ? void 0 : _a.classList.remove('hidden');
2276
+ }
2277
+ end() {
2278
+ var _a;
2279
+ (_a = this.el) === null || _a === void 0 ? void 0 : _a.classList.add('hidden');
2280
+ }
2281
+ move(pos) {
2282
+ this.moveElement(pos.end - this.parentY);
2283
+ }
2284
+ moveTip({ x, y }) {
2285
+ if (!this.draggable) {
2286
+ return;
2287
+ }
2288
+ this.draggable.style.left = `${x}px`;
2289
+ this.draggable.style.top = `${y}px`;
2290
+ }
2291
+ moveElement(y) {
2292
+ if (!this.rgRow) {
2293
+ return;
2294
+ }
2295
+ this.rgRow.style.transform = `translateY(${y}px)`;
2296
+ }
2297
+ }
2298
+ const OrderRenderer = ({ ref }) => {
2299
+ const service = new OrdererService();
2300
+ ref(service);
2301
+ return (h("div", { class: "draggable-wrapper hidden", ref: e => (service.el = e) },
2302
+ h("div", { class: "draggable", ref: el => (service.draggable = el) },
2303
+ h("span", { class: "revo-alt-icon" }),
2304
+ h("span", { ref: e => (service.text = e) })),
2305
+ h("div", { class: "drag-position", ref: e => (service.rgRow = e) })));
2306
+ };
2307
+
2308
+ const RevoViewPort = ({ viewports, dimensions, orderRef, nakedClick, registerElement, onScroll }, children) => {
2309
+ const viewPortClick = (e, el) => {
2310
+ if (el === e.target) {
2311
+ nakedClick(e);
2312
+ }
2313
+ };
2314
+ let el;
2315
+ return [
2316
+ h("div", { class: "main-viewport", ref: e => el = e, onClick: e => viewPortClick(e, el) },
2317
+ h("div", { class: "viewports" },
2318
+ children,
2319
+ h("revogr-scroll-virtual", { class: "vertical", dimension: "rgRow", viewportStore: viewports['rgRow'].store, dimensionStore: dimensions['rgRow'].store, ref: el => registerElement(el, 'rowScroll'), onScrollVirtual: e => onScroll(e.detail) }),
2320
+ h(OrderRenderer, { ref: orderRef }))),
2321
+ h("revogr-scroll-virtual", { class: "horizontal", dimension: "rgCol", viewportStore: viewports['rgCol'].store, dimensionStore: dimensions['rgCol'].store, ref: el => registerElement(el, 'colScroll'), onScrollVirtual: e => onScroll(e.detail) }),
2322
+ ];
2323
+ };
2324
+
2325
+ class ViewportService {
2326
+ constructor(sv, contentHeight) {
2327
+ var _a, _b;
2328
+ this.sv = sv;
2329
+ this.storesByType = {};
2330
+ this.storesXToType = {};
2331
+ this.storesYToType = {};
2332
+ (_a = this.sv.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.beforeUpdate();
2333
+ this.columns = this.getViewportColumnData(contentHeight);
2334
+ (_b = this.sv.scrollingService) === null || _b === void 0 ? void 0 : _b.unregister();
2335
+ }
2336
+ onColumnResize(type, e, store) {
2337
+ var _a;
2338
+ (_a = this.sv.dimensionProvider) === null || _a === void 0 ? void 0 : _a.setDimensionSize(type, e.detail);
2339
+ const changedItems = lodash.reduce(e.detail || {}, (r, size, index) => {
2340
+ const item = getSourceItem(store, parseInt(index, 10));
2341
+ if (item) {
2342
+ r[item.prop] = Object.assign(Object.assign({}, item), { size });
2343
+ }
2344
+ return r;
2345
+ }, {});
2346
+ this.sv.resize(changedItems);
2347
+ }
2348
+ /**
2349
+ * Transform data from stores and apply it to different components
2350
+ */
2351
+ getViewportColumnData(contentHeight) {
2352
+ const columns = [];
2353
+ let x = 0; // we increase x only if column present
2354
+ columnTypes.forEach(val => {
2355
+ const colStore = this.sv.columnProvider.stores[val].store;
2356
+ // only columns that have data show
2357
+ if (!colStore.get('items').length) {
2358
+ return;
2359
+ }
2360
+ const column = {
2361
+ colType: val,
2362
+ position: { x, y: 1 },
2363
+ contentHeight,
2364
+ fixWidth: val !== 'rgCol',
2365
+ uuid: `${this.sv.uuid}-${x}`,
2366
+ viewports: this.sv.viewportProvider.stores,
2367
+ dimensions: this.sv.dimensionProvider.stores,
2368
+ rowStores: this.sv.dataProvider.stores,
2369
+ colStore,
2370
+ onHeaderresize: e => this.onColumnResize(val, e, colStore)
2371
+ };
2372
+ if (val === 'rgCol') {
2373
+ column.onResizeViewport = (e) => { var _a; return (_a = this.sv.viewportProvider) === null || _a === void 0 ? void 0 : _a.setViewport(e.detail.dimension, { virtualSize: e.detail.size }); };
2374
+ }
2375
+ const colData = this.gatherColumnData(column);
2376
+ const columnSelectionStore = this.registerCol(colData.position.x, val);
2377
+ // render per each column data collections vertically
2378
+ const dataPorts = this.dataViewPort(column).reduce((r, rgRow) => {
2379
+ // register selection store for Segment
2380
+ const segmentSelection = this.registerSegment(rgRow.position);
2381
+ segmentSelection.setLastCell(rgRow.lastCell);
2382
+ // register selection store for Row
2383
+ const rowSelectionStore = this.registerRow(rgRow.position.y, rgRow.type);
2384
+ const rowDef = Object.assign(Object.assign({}, rgRow), { rowSelectionStore, segmentSelectionStore: segmentSelection.store, ref: (e) => this.sv.selectionStoreConnector.registerSection(e), onSetRange: e => segmentSelection.setRangeArea(e.detail), onSetTempRange: e => segmentSelection.setTempArea(e.detail), onFocusCell: e => {
2385
+ segmentSelection.clearFocus();
2386
+ this.sv.selectionStoreConnector.focus(segmentSelection, e.detail);
2387
+ } });
2388
+ r.push(rowDef);
2389
+ return r;
2390
+ }, []);
2391
+ columns.push(Object.assign(Object.assign({}, colData), { columnSelectionStore,
2392
+ dataPorts }));
2393
+ x++;
2394
+ });
2395
+ return columns;
2396
+ }
2397
+ /** register selection store for Segment */
2398
+ registerSegment(position) {
2399
+ return this.sv.selectionStoreConnector.register(position);
2400
+ }
2401
+ /** register selection store for Row */
2402
+ registerRow(y, type) {
2403
+ // link to position
2404
+ this.storesByType[type] = y;
2405
+ this.storesYToType[y] = type;
2406
+ return this.sv.selectionStoreConnector.registerRow(y).store;
2407
+ }
2408
+ /** register selection store for Column */
2409
+ registerCol(x, type) {
2410
+ // link to position
2411
+ this.storesByType[type] = x;
2412
+ this.storesXToType[x] = type;
2413
+ return this.sv.selectionStoreConnector.registerColumn(x).store;
2414
+ }
2415
+ /** Collect Column data */
2416
+ gatherColumnData(data) {
2417
+ const parent = data.uuid;
2418
+ const realSize = data.dimensions[data.colType].store.get('realSize');
2419
+ const prop = {
2420
+ contentWidth: realSize,
2421
+ class: data.colType,
2422
+ [`${UUID}`]: data.uuid,
2423
+ contentHeight: data.contentHeight,
2424
+ key: data.colType,
2425
+ onResizeViewport: data.onResizeViewport,
2426
+ };
2427
+ if (data.fixWidth) {
2428
+ prop.style = { minWidth: `${realSize}px` };
2429
+ }
2430
+ const headerProp = {
2431
+ parent,
2432
+ colData: getVisibleSourceItem(data.colStore),
2433
+ dimensionCol: data.dimensions[data.colType].store,
2434
+ groups: data.colStore.get('groups'),
2435
+ groupingDepth: data.colStore.get('groupingDepth'),
2436
+ onHeaderresize: data.onHeaderresize,
2437
+ };
2438
+ return {
2439
+ prop,
2440
+ position: data.position,
2441
+ headerProp,
2442
+ parent,
2443
+ viewportCol: data.viewports[data.colType].store,
2444
+ };
2445
+ }
2446
+ /** Collect Row data */
2447
+ dataViewPort(data) {
2448
+ const slots = {
2449
+ rowPinStart: HEADER_SLOT,
2450
+ rgRow: CONTENT_SLOT,
2451
+ rowPinEnd: FOOTER_SLOT,
2452
+ };
2453
+ // y position for selection
2454
+ let y = 0;
2455
+ return rowTypes.reduce((r, type) => {
2456
+ // filter out empty sources, we still need to return source to keep slot working
2457
+ const isPresent = data.viewports[type].store.get('realCount') || type === 'rgRow';
2458
+ const rgCol = Object.assign(Object.assign({}, data), { position: Object.assign(Object.assign({}, data.position), { y: isPresent ? y : EMPTY_INDEX }) });
2459
+ r.push(this.dataPartition(rgCol, type, slots[type], type !== 'rgRow'));
2460
+ if (isPresent) {
2461
+ y++;
2462
+ }
2463
+ return r;
2464
+ }, []);
2465
+ }
2466
+ dataPartition(data, type, slot, fixed) {
2467
+ return {
2468
+ colData: data.colStore,
2469
+ viewportCol: data.viewports[data.colType].store,
2470
+ viewportRow: data.viewports[type].store,
2471
+ lastCell: getLastCell(data, type),
2472
+ slot,
2473
+ type,
2474
+ canDrag: !fixed,
2475
+ position: data.position,
2476
+ uuid: `${data.uuid}-${data.position.x}-${data.position.y}`,
2477
+ dataStore: data.rowStores[type].store,
2478
+ dimensionCol: data.dimensions[data.colType].store,
2479
+ dimensionRow: data.dimensions[type].store,
2480
+ style: fixed ? { height: `${data.dimensions[type].store.get('realSize')}px` } : undefined,
2481
+ };
2482
+ }
2483
+ scrollToCell(cell) {
2484
+ for (let key in cell) {
2485
+ const coordinate = cell[key];
2486
+ this.sv.scrollingService.onScroll({ dimension: key === 'x' ? 'rgCol' : 'rgRow', coordinate });
2487
+ }
2488
+ }
2489
+ /**
2490
+ * Clear current grid focus
2491
+ */
2492
+ clearFocused() {
2493
+ this.sv.selectionStoreConnector.clearAll();
2494
+ }
2495
+ clearEdit() {
2496
+ this.sv.selectionStoreConnector.setEdit(false);
2497
+ }
2498
+ getFocused() {
2499
+ const focused = this.sv.selectionStoreConnector.focusedStore;
2500
+ if (!focused) {
2501
+ return null;
2502
+ }
2503
+ const colType = this.storesXToType[focused.position.x];
2504
+ const column = this.sv.columnProvider.getColumn(focused.cell.x, colType);
2505
+ const rowType = this.storesYToType[focused.position.x];
2506
+ const model = this.sv.dataProvider.getModel(focused.cell.x, rowType);
2507
+ return {
2508
+ column,
2509
+ model,
2510
+ cell: focused.cell,
2511
+ colType,
2512
+ rowType
2513
+ };
2514
+ }
2515
+ getSelectedRange() {
2516
+ return this.sv.selectionStoreConnector.selectedRange;
2517
+ }
2518
+ setEdit(rowIndex, colIndex, colType, rowType) {
2519
+ var _a;
2520
+ const stores = this.storesByType;
2521
+ const storeCoordinate = {
2522
+ x: stores[colType],
2523
+ y: stores[rowType],
2524
+ };
2525
+ (_a = this.sv.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEditByCell(storeCoordinate, { x: colIndex, y: rowIndex });
2526
+ }
2527
+ }
2528
+
2529
+ /**
2530
+ * All render based on sections
2531
+ * First we render vertical parts - pinned start, data, pinned end
2532
+ * Per each column we render data collections: headers, pinned top, center data, pinned bottom
2533
+ */
2534
+ const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns, useClipboard, columnFilter, registerElement, onEdit, onScroll }) => {
2535
+ const viewPortHtml = [];
2536
+ /** render viewports columns */
2537
+ for (let view of columns) {
2538
+ /** render viewports rows */
2539
+ const dataViews = [
2540
+ h("revogr-header", Object.assign({ viewportCol: view.viewportCol }, view.headerProp, { selectionStore: view.columnSelectionStore, slot: HEADER_SLOT, columnFilter: columnFilter, canResize: resize })),
2541
+ ];
2542
+ view.dataPorts.forEach((data, j) => {
2543
+ const key = view.prop.key + (j + 1);
2544
+ const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { slot: data.slot, selectionStore: data.segmentSelectionStore, editors: editors, readonly: readonly, range: range, useClipboard: useClipboard, onSetEdit: ({ detail }) => onEdit(detail) }),
2545
+ h("revogr-data", Object.assign({}, data, { [UUID]: data.uuid }, { key: key, readonly: readonly, range: range, rowClass: rowClass, rowSelectionStore: data.rowSelectionStore, slot: DATA_SLOT })),
2546
+ h("revogr-temp-range", { selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }),
2547
+ h("revogr-focus", { selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol })));
2548
+ dataViews.push(dataView);
2549
+ });
2550
+ viewPortHtml.push(h("revogr-viewport-scroll", Object.assign({}, view.prop, { ref: el => registerElement(el, view.prop.key), onScrollViewport: e => onScroll(e.detail, view.prop.key) }), dataViews));
2551
+ }
2552
+ return viewPortHtml;
2553
+ };
2554
+
2555
+ class GridScrollingService {
2556
+ constructor(setViewport) {
2557
+ this.setViewport = setViewport;
2558
+ this.elements = {};
2559
+ }
2560
+ async onScroll(e, key) {
2561
+ let newEvent;
2562
+ for (let elKey in this.elements) {
2563
+ if (this.isPinnedColumn(key) && e.dimension === 'rgCol') {
2564
+ if (elKey === key || !e.delta) {
2565
+ continue;
2566
+ }
2567
+ for (let el of this.elements[elKey]) {
2568
+ el.changeScroll && (newEvent = el.changeScroll(e));
2569
+ }
2570
+ }
2571
+ else if (e.dimension === 'rgCol' && elKey === 'headerRow') {
2572
+ continue;
2573
+ }
2574
+ else {
2575
+ for (let el of this.elements[elKey]) {
2576
+ el.setScroll(e);
2577
+ }
2578
+ }
2579
+ }
2580
+ let event = e;
2581
+ if (newEvent) {
2582
+ event = await newEvent;
2583
+ }
2584
+ this.setViewport(event);
2585
+ }
2586
+ isPinnedColumn(key) {
2587
+ return ['colPinStart', 'colPinEnd'].indexOf(key) > -1;
2588
+ }
2589
+ registerElements(els) {
2590
+ this.elements = els;
2591
+ }
2592
+ /**
2593
+ * Register new element for farther scroll support
2594
+ * @param el - can be null if holder removed
2595
+ * @param key - element key
2596
+ */
2597
+ registerElement(el, key) {
2598
+ if (!this.elements[key]) {
2599
+ this.elements[key] = [];
2600
+ }
2601
+ // new element added
2602
+ if (el) {
2603
+ this.elements[key].push(el);
2604
+ }
2605
+ else if (this.elements[key]) {
2606
+ // element removed
2607
+ delete this.elements[key];
2608
+ }
2609
+ }
2610
+ unregister() {
2611
+ delete this.elements;
2612
+ this.elements = {};
2613
+ }
2614
+ }
2615
+
2616
+ class StretchColumn extends BasePlugin {
2617
+ constructor(revogrid, dimensionProvider) {
2618
+ super(revogrid);
2619
+ this.dimensionProvider = dimensionProvider;
2620
+ this.stretchedColumn = null;
2621
+ this.scrollSize = getScrollbarWidth(document);
2622
+ const beforecolumnapplied = ({ detail: { columns } }) => this.applyStretch(columns);
2623
+ this.addEventListener('beforecolumnapplied', beforecolumnapplied);
2624
+ }
2625
+ setScroll({ type, hasScroll }) {
2626
+ var _a;
2627
+ if (type === 'rgRow' && this.stretchedColumn && ((_a = this.stretchedColumn) === null || _a === void 0 ? void 0 : _a.initialSize) === this.stretchedColumn.size) {
2628
+ if (hasScroll) {
2629
+ this.stretchedColumn.size -= this.scrollSize;
2630
+ this.apply();
2631
+ this.dropChanges();
2632
+ }
2633
+ }
2634
+ }
2635
+ activateChanges() {
2636
+ const setScroll = ({ detail }) => this.setScroll(detail);
2637
+ this.addEventListener('scrollchange', setScroll);
2638
+ }
2639
+ dropChanges() {
2640
+ this.stretchedColumn = null;
2641
+ this.removeEventListener('scrollchange');
2642
+ }
2643
+ apply() {
2644
+ if (!this.stretchedColumn) {
2645
+ return;
2646
+ }
2647
+ const type = 'rgCol';
2648
+ this.dimensionProvider.setDimensionSize(type, { [this.stretchedColumn.index]: this.stretchedColumn.size });
2649
+ }
2650
+ applyStretch(columns) {
2651
+ this.dropChanges();
2652
+ let sizeDifference = this.revogrid.clientWidth - 1;
2653
+ lodash.each(columns, (_c, type) => {
2654
+ const realSize = this.dimensionProvider.stores[type].store.get('realSize');
2655
+ sizeDifference -= realSize;
2656
+ });
2657
+ if (sizeDifference > 0) {
2658
+ // currently plugin accepts last column
2659
+ const index = columns.rgCol.length - 1;
2660
+ const last = columns.rgCol[index];
2661
+ // has column
2662
+ // no auto size applied
2663
+ // size for column shouldn't be defined
2664
+ const colSize = (last === null || last === void 0 ? void 0 : last.size) || this.revogrid.colSize || 0;
2665
+ const size = sizeDifference + colSize - 1;
2666
+ if (last && !last.autoSize && (colSize < size)) {
2667
+ this.stretchedColumn = {
2668
+ initialSize: size,
2669
+ index,
2670
+ size
2671
+ };
2672
+ this.apply();
2673
+ this.activateChanges();
2674
+ }
2675
+ }
2676
+ }
2677
+ }
2678
+ function isStretchPlugin(plugin) {
2679
+ return !!plugin.applyStretch;
2680
+ }
2681
+
2682
+ class ColumnOrderHandler {
2683
+ constructor() {
2684
+ this.offset = 0;
2685
+ }
2686
+ renderAutoscroll(_, parent) {
2687
+ if (!parent) {
2688
+ return;
2689
+ }
2690
+ this.autoscrollEl = document.createElement('div');
2691
+ this.autoscrollEl.classList.add('drag-auto-scroll-y');
2692
+ parent.appendChild(this.autoscrollEl);
2693
+ }
2694
+ autoscroll(pos, dataContainerSize, direction = 'translateX') {
2695
+ if (!this.autoscrollEl) {
2696
+ return;
2697
+ }
2698
+ const helperOffset = 10;
2699
+ // calculate current y position inside of the grid active holder
2700
+ // 3 - size of element + border
2701
+ const maxScroll = Math.min(pos + helperOffset, dataContainerSize - 3);
2702
+ this.autoscrollEl.style.transform = `${direction}(${maxScroll}px)`;
2703
+ this.autoscrollEl.scrollIntoView({
2704
+ block: 'nearest',
2705
+ inline: 'nearest',
2706
+ });
2707
+ }
2708
+ start(e, { el, gridRect, elScroll }, dir = 'left') {
2709
+ const scrollContainerRect = elScroll.getBoundingClientRect();
2710
+ if (scrollContainerRect) {
2711
+ this.offset = scrollContainerRect[dir] - gridRect[dir];
2712
+ }
2713
+ this.renderAutoscroll(e, el);
2714
+ }
2715
+ stop() {
2716
+ var _a;
2717
+ if (this.element) {
2718
+ this.element.hidden = true;
2719
+ }
2720
+ (_a = this.autoscrollEl) === null || _a === void 0 ? void 0 : _a.remove();
2721
+ this.autoscrollEl = undefined;
2722
+ this.offset = 0;
2723
+ }
2724
+ showHandler(pos, size, direction = 'translateX') {
2725
+ if (!this.element) {
2726
+ return;
2727
+ }
2728
+ // do not allow overcross top of the scrollable area, header excluded
2729
+ if (this.offset) {
2730
+ pos = Math.max(pos, this.offset);
2731
+ }
2732
+ // can not be bigger then grid end
2733
+ pos = Math.min(pos, size);
2734
+ this.element.style.transform = `${direction}(${pos}px)`;
2735
+ this.element.hidden = false;
2736
+ }
2737
+ render() {
2738
+ return h("div", { class: "drag-position-y", hidden: true, ref: (el) => (this.element = el) });
2739
+ }
2740
+ }
2741
+
2742
+ /**
2743
+ * Plugin for column manual move
2744
+ */
2745
+ const COLUMN_CLICK = 'column-click';
2746
+ const MOVE = 'column-mouse-move';
2747
+ const DRAG_END = 'column-drag-end';
2748
+ const BEFORE_DRAG_END = 'before-column-drag-end';
2749
+ // use this event subscription to drop D&D for particular columns
2750
+ const DRAG_START = 'column-drag-start';
2751
+ class ColumnPlugin extends BasePlugin {
2752
+ constructor(revogrid, providers) {
2753
+ super(revogrid);
2754
+ this.revogrid = revogrid;
2755
+ this.providers = providers;
2756
+ this.moveFunc = debounce_1((e) => this.doMove(e), 5);
2757
+ this.staticDragData = null;
2758
+ this.dragData = null;
2759
+ this.localSubscriptions = {};
2760
+ this.orderUi = new ColumnOrderHandler();
2761
+ revogrid.registerVNode([this.orderUi.render()]);
2762
+ /** Register events */
2763
+ this.localSubscriptions['mouseleave'] = {
2764
+ target: document,
2765
+ callback: (e) => this.onMouseOut(e),
2766
+ };
2767
+ this.localSubscriptions['mouseup'] = {
2768
+ target: document,
2769
+ callback: (e) => this.onMouseUp(e),
2770
+ };
2771
+ this.localSubscriptions['mousemove'] = {
2772
+ target: document,
2773
+ callback: (e) => this.move(e),
2774
+ };
2775
+ this.addEventListener(COLUMN_CLICK, ({ detail }) => this.dragStart(detail));
2776
+ }
2777
+ dragStart({ event, data }) {
2778
+ const { defaultPrevented } = dispatch(this.revogrid, DRAG_START, data);
2779
+ // check if allowed to drag particulat column
2780
+ if (defaultPrevented) {
2781
+ return;
2782
+ }
2783
+ this.clearOrder();
2784
+ const { mouseleave, mouseup, mousemove } = this.localSubscriptions;
2785
+ mouseleave.target.addEventListener('mouseleave', mouseleave.callback);
2786
+ mouseup.target.addEventListener('mouseup', mouseup.callback);
2787
+ const dataEl = event.target.closest('revogr-header');
2788
+ const scrollEl = event.target.closest('revogr-viewport-scroll');
2789
+ if (!dataEl || !scrollEl) {
2790
+ return;
2791
+ }
2792
+ this.staticDragData = {
2793
+ startPos: event.x,
2794
+ data,
2795
+ dataEl,
2796
+ scrollEl,
2797
+ gridEl: this.revogrid,
2798
+ };
2799
+ this.dragData = this.getData(this.staticDragData);
2800
+ mousemove.target.addEventListener('mousemove', mousemove.callback);
2801
+ this.orderUi.start(event, this.dragData);
2802
+ }
2803
+ doMove(e) {
2804
+ if (!this.staticDragData) {
2805
+ return;
2806
+ }
2807
+ const dragData = (this.dragData = this.getData(this.staticDragData));
2808
+ if (!dragData) {
2809
+ return;
2810
+ }
2811
+ const start = this.staticDragData.startPos;
2812
+ if (Math.abs(start - e.x) > 10) {
2813
+ const x = getLeftRelative(e.x, dragData);
2814
+ const rgCol = getItemByPosition(dragData.cols, x);
2815
+ this.orderUi.autoscroll(x, dragData.elRect.width);
2816
+ this.orderUi.showHandler(rgCol.end + dragData.xOffset, dragData.gridRect.width);
2817
+ }
2818
+ }
2819
+ move(e) {
2820
+ dispatch(this.revogrid, MOVE, Object.assign({}, e));
2821
+ // then do move
2822
+ this.moveFunc(e);
2823
+ }
2824
+ onMouseOut(_) {
2825
+ this.clearOrder();
2826
+ }
2827
+ onMouseUp(e) {
2828
+ // apply new positions
2829
+ if (this.dragData) {
2830
+ const newItem = getItemByPosition(this.dragData.cols, getLeftRelative(e.x, this.dragData));
2831
+ const startItem = getItemByPosition(this.dragData.cols, getLeftRelative(this.staticDragData.startPos, this.dragData));
2832
+ // prevent position change if needed
2833
+ const { defaultPrevented: stopDrag } = dispatch(this.revogrid, BEFORE_DRAG_END, Object.assign(Object.assign({}, this.staticDragData), { startPosition: startItem, newPosition: newItem }));
2834
+ if (!stopDrag) {
2835
+ const store = this.providers.column.stores[this.dragData.type].store;
2836
+ const items = [...store.get('items')];
2837
+ const toMove = items.splice(startItem.itemIndex, 1);
2838
+ items.splice(newItem.itemIndex, 0, ...toMove);
2839
+ store.set('items', items);
2840
+ }
2841
+ dispatch(this.revogrid, DRAG_END, this.dragData);
2842
+ }
2843
+ this.clearOrder();
2844
+ }
2845
+ clearLocalSubscriptions() {
2846
+ each(this.localSubscriptions, ({ target, callback }, key) => target.removeEventListener(key, callback));
2847
+ }
2848
+ clearOrder() {
2849
+ this.clearLocalSubscriptions();
2850
+ this.orderUi.stop();
2851
+ }
2852
+ /**
2853
+ * Clearing subscription
2854
+ */
2855
+ clearSubscriptions() {
2856
+ super.clearSubscriptions();
2857
+ this.clearLocalSubscriptions();
2858
+ }
2859
+ getData({ gridEl, dataEl, scrollEl, data, }) {
2860
+ const gridRect = gridEl.getBoundingClientRect();
2861
+ const elRect = dataEl.getBoundingClientRect();
2862
+ return {
2863
+ el: dataEl,
2864
+ elScroll: scrollEl,
2865
+ elRect,
2866
+ gridRect,
2867
+ data,
2868
+ type: data.pin || 'rgCol',
2869
+ xOffset: elRect.left - gridRect.left,
2870
+ rows: this.getDimension('rgRow'),
2871
+ cols: this.getDimension('rgCol'),
2872
+ };
2873
+ }
2874
+ getDimension(type) {
2875
+ return this.providers.dimension.stores[type].getCurrentState();
2876
+ }
2877
+ }
2878
+ function getLeftRelative(absoluteX, { xOffset, gridRect }) {
2879
+ return absoluteX - gridRect.left - xOffset;
2880
+ }
2881
+
2882
+ const revoGridStyleCss = ".revo-drag-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:7px;background-size:cover;background-repeat:no-repeat}.revo-alt-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:11px;background-size:cover;background-repeat:no-repeat}.arrow-down{position:absolute;right:5px;top:0}.arrow-down svg{width:8px;margin-top:5px;margin-left:5px;opacity:0.4}.cell-value-wrapper{margin-right:10px;overflow:hidden;text-overflow:ellipsis}.revo-button{position:relative;overflow:hidden;color:#fff;background-color:#6200ee;height:34px;line-height:34px;padding:0 15px;outline:0;border:0;border-radius:7px;box-sizing:border-box;cursor:pointer}.revo-button.green{background-color:#2ee072;border:1px solid #20d565}.revo-button.red{background-color:#E0662E;border:1px solid #d55920}.revo-button:disabled,.revo-button[disabled]{cursor:not-allowed !important;filter:opacity(0.35) !important}.revo-button.light{border:2px solid #cedefa;line-height:32px;background:none;color:#4876ca;box-shadow:none}revo-grid[theme=default]{font-size:12px}revo-grid[theme=default] revogr-header{text-align:center;line-height:30px;background-color:#f8f9fa}revo-grid[theme=default] revogr-header .group-rgRow{box-shadow:none}revo-grid[theme=default] revogr-header .header-rgRow,revo-grid[theme=default] revogr-header .group-rgRow{text-transform:uppercase;font-size:12px;color:#61656a}revo-grid[theme=default] revogr-header .header-rgRow{height:30px;box-shadow:0 -1px 0 0 #c0c0c0 inset}revo-grid[theme=default] revogr-header .rgHeaderCell{box-shadow:-1px 0 0 0 #c0c0c0, -1px 0 0 0 #c0c0c0 inset, 0 -1px 0 0 #c0c0c0, 0 -1px 0 0 #c0c0c0 inset}revo-grid[theme=default] revogr-header .rgHeaderCell.focused-cell{background:rgba(233, 234, 237, 0.5)}revo-grid[theme=default] .rowHeaders{background-color:#f8f9fa}revo-grid[theme=default] .rowHeaders revogr-data .rgCell{color:#61656a;box-shadow:0 -1px 0 0 #c0c0c0 inset, -1px 0 0 0 #c0c0c0 inset}revo-grid[theme=default] .rowHeaders revogr-header{box-shadow:0 -1px 0 0 #c0c0c0 inset, -1px 0 0 0 #c0c0c0 inset}revo-grid[theme=default] revogr-viewport-scroll.colPinStart revogr-data .rgRow .rgCell:last-child{box-shadow:0 -1px 0 0 #e2e3e3 inset, -1px 0 0 0 #c0c0c0 inset}revo-grid[theme=default] revogr-viewport-scroll.colPinStart .footer-wrapper revogr-data .rgRow:first-child .rgCell{box-shadow:0 1px 0 0 #c0c0c0 inset, -1px 0 0 0 #c0c0c0 inset}revo-grid[theme=default] revogr-viewport-scroll.colPinEnd,revo-grid[theme=default] revogr-viewport-scroll.colPinEnd revogr-header{box-shadow:1px 0 0 #c0c0c0 inset}revo-grid[theme=default] .footer-wrapper revogr-data .rgRow:first-child .rgCell{box-shadow:0 1px 0 0 #e2e3e3 inset, -1px 0 0 0 #e2e3e3 inset, 0 -1px 0 0 #e2e3e3 inset}revo-grid[theme=default] revogr-data{text-align:center}revo-grid[theme=default] revogr-data .rgRow{line-height:27px;box-shadow:0 -1px 0 0 #e2e3e3 inset, -1px 0 0 0 #e2e3e3 inset}revo-grid[theme=default] revogr-data .rgRow.focused-rgRow{background-color:rgba(233, 234, 237, 0.5)}revo-grid[theme=default] revogr-data .rgCell{box-shadow:0 -1px 0 0 #e2e3e3 inset, -1px 0 0 0 #e2e3e3 inset}revo-grid[theme=default] revogr-data .rgCell.disabled{background-color:0 -1px 0 0 #e2e3e3 inset, -1px 0 0 0 #e2e3e3 inset}revo-grid[theme=material]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}revo-grid[theme=material] revogr-header{line-height:50px;font-weight:600;text-align:left}revo-grid[theme=material] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=material] revogr-header .header-rgRow{height:50px}revo-grid[theme=material] revogr-data{text-align:left}revo-grid[theme=material] revogr-data .rgRow{line-height:42px}revo-grid[theme=material] revogr-data .rgCell{padding:0 15px}revo-grid[theme=material] .viewports{width:100%}revo-grid[theme=material] .rowHeaders{background-color:#f7faff}revo-grid[theme=material] .rowHeaders revogr-data .rgCell{color:#757a82}revo-grid[theme=material] revogr-header .header-rgRow.group{box-shadow:0 -1px 0 0 #f1f1f1 inset}revo-grid[theme=material] revogr-header .header-rgRow:not(.group){box-shadow:0 -1px 0 0 #f1f1f1, 0 -1px 0 0 #f1f1f1 inset}revo-grid[theme=material] revogr-header .rgHeaderCell.sortable:hover{background-color:#f1f1f1}revo-grid[theme=material] revogr-header .rgHeaderCell.focused-cell{background:rgba(233, 234, 237, 0.5)}revo-grid[theme=material] .footer-wrapper revogr-data{box-shadow:0 -1px 0 #f1f1f1}revo-grid[theme=material] revogr-viewport-scroll.colPinStart{box-shadow:-1px 0 0 #f1f1f1 inset}revo-grid[theme=material] revogr-viewport-scroll.colPinEnd{box-shadow:-1px 0 0 #f1f1f1}revo-grid[theme=material] revogr-data .rgRow{box-shadow:0 -1px 0 0 #f1f1f1 inset}revo-grid[theme=material] revogr-data .rgRow.focused-rgRow{background-color:rgba(233, 234, 237, 0.5)}revo-grid[theme=material] revogr-data .rgCell{color:rgba(0, 0, 0, 0.87)}revo-grid[theme=material] revogr-data .rgCell.disabled{background-color:#f7f7f7}revo-grid[theme=material] revogr-data .revo-draggable>.revo-drag-icon{background-color:#d4d4d4}revo-grid[theme=material] revogr-data .revo-draggable:hover>.revo-drag-icon{background-color:black}revo-grid[theme=darkMaterial]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";color:#d8d8d8}revo-grid[theme=darkMaterial] revogr-header{line-height:50px;font-weight:600;text-align:left}revo-grid[theme=darkMaterial] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=darkMaterial] revogr-header .header-rgRow{height:50px}revo-grid[theme=darkMaterial] revogr-data{text-align:left}revo-grid[theme=darkMaterial] revogr-data .rgRow{line-height:42px}revo-grid[theme=darkMaterial] revogr-data .rgCell{padding:0 15px}revo-grid[theme=darkMaterial] .viewports{width:100%}revo-grid[theme=darkMaterial] .rowHeaders{background-color:rgba(40, 39, 43, 0.8)}revo-grid[theme=darkMaterial] .rowHeaders revogr-data .rgCell{color:rgba(216, 216, 216, 0.8)}revo-grid[theme=darkMaterial] revogr-header .header-rgRow.group{box-shadow:0 -1px 0 0 #404040 inset}revo-grid[theme=darkMaterial] revogr-header .header-rgRow:not(.group){box-shadow:0 -1px 0 0 #404040, 0 -1px 0 0 #404040 inset}revo-grid[theme=darkMaterial] revogr-header .rgHeaderCell.sortable:hover{background-color:rgba(64, 64, 64, 0.5)}revo-grid[theme=darkMaterial] revogr-header .rgHeaderCell.focused-cell{background:rgba(115, 148, 160, 0.15)}revo-grid[theme=darkMaterial] .footer-wrapper revogr-data{box-shadow:0 -1px 0 #404040}revo-grid[theme=darkMaterial] revogr-data .rgCell{color:rgba(216, 216, 216, 0.9)}revo-grid[theme=darkMaterial] revogr-data .rgRow{box-shadow:0 -1px 0 0 #404040 inset}revo-grid[theme=darkMaterial] revogr-data .rgRow.focused-rgRow{background-color:rgba(115, 148, 160, 0.15)}revo-grid[theme=darkMaterial] revogr-data .revo-draggable>.revo-drag-icon{background-color:rgba(216, 216, 216, 0.5)}revo-grid[theme=darkMaterial] revogr-data .revo-draggable:hover>.revo-drag-icon{background-color:rgba(216, 216, 216, 0.7)}revo-grid[theme=darkMaterial] revogr-viewport-scroll.colPinStart{box-shadow:-1px 0 0 #404040 inset}revo-grid[theme=darkMaterial] revogr-viewport-scroll.colPinEnd{box-shadow:-1px 0 0 #404040}revo-grid[theme=darkCompact]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";color:#d8d8d8}revo-grid[theme=darkCompact] revogr-header{line-height:45px;font-weight:600;text-align:left}revo-grid[theme=darkCompact] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=darkCompact] revogr-header .header-rgRow{height:45px}revo-grid[theme=darkCompact] revogr-data{text-align:left}revo-grid[theme=darkCompact] revogr-data .rgRow{line-height:32px}revo-grid[theme=darkCompact] revogr-data .rgCell{padding:0 15px}revo-grid[theme=darkCompact] .viewports{width:100%}revo-grid[theme=darkCompact] .rowHeaders{background-color:rgba(40, 39, 43, 0.8)}revo-grid[theme=darkCompact] .rowHeaders revogr-data .rgCell{color:rgba(216, 216, 216, 0.8)}revo-grid[theme=darkCompact] revogr-header .header-rgRow.group{box-shadow:0 -1px 0 0 #404040 inset}revo-grid[theme=darkCompact] revogr-header .header-rgRow:not(.group){box-shadow:0 -1px 0 0 #404040, 0 -1px 0 0 #404040 inset}revo-grid[theme=darkCompact] revogr-header .rgHeaderCell.sortable:hover{background-color:rgba(64, 64, 64, 0.5)}revo-grid[theme=darkCompact] revogr-header .rgHeaderCell.focused-cell{background:rgba(115, 148, 160, 0.15)}revo-grid[theme=darkCompact] .footer-wrapper revogr-data{box-shadow:0 -1px 0 #404040}revo-grid[theme=darkCompact] revogr-data .rgCell{color:rgba(216, 216, 216, 0.9)}revo-grid[theme=darkCompact] revogr-data .rgRow{box-shadow:0 -1px 0 0 #404040 inset}revo-grid[theme=darkCompact] revogr-data .rgRow.focused-rgRow{background-color:rgba(115, 148, 160, 0.15)}revo-grid[theme=darkCompact] revogr-data .revo-draggable>.revo-drag-icon{background-color:rgba(216, 216, 216, 0.5)}revo-grid[theme=darkCompact] revogr-data .revo-draggable:hover>.revo-drag-icon{background-color:rgba(216, 216, 216, 0.7)}revo-grid[theme=darkCompact] revogr-viewport-scroll.colPinStart{box-shadow:-1px 0 0 #404040 inset}revo-grid[theme=darkCompact] revogr-viewport-scroll.colPinEnd{box-shadow:-1px 0 0 #404040}revo-grid[theme=compact]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}revo-grid[theme=compact] revogr-header{line-height:45px;font-weight:600;text-align:left}revo-grid[theme=compact] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=compact] revogr-header .header-rgRow{height:45px}revo-grid[theme=compact] revogr-data{text-align:left}revo-grid[theme=compact] revogr-data .rgRow{line-height:32px}revo-grid[theme=compact] revogr-data .rgCell{padding:0 15px}revo-grid[theme=compact] .viewports{width:100%}revo-grid[theme=compact] .rowHeaders{background-color:#f7faff}revo-grid[theme=compact] .rowHeaders revogr-data .rgCell{color:#757a82}revo-grid[theme=compact] revogr-header .header-rgRow.group{box-shadow:0 -1px 0 0 #f1f1f1 inset}revo-grid[theme=compact] revogr-header .header-rgRow:not(.group){box-shadow:0 -1px 0 0 #f1f1f1, 0 -1px 0 0 #f1f1f1 inset}revo-grid[theme=compact] revogr-header .rgHeaderCell.sortable:hover{background-color:#f1f1f1}revo-grid[theme=compact] revogr-header .rgHeaderCell.focused-cell{background:rgba(233, 234, 237, 0.5)}revo-grid[theme=compact] .footer-wrapper revogr-data{box-shadow:0 -1px 0 #f1f1f1}revo-grid[theme=compact] revogr-viewport-scroll.colPinStart{box-shadow:-1px 0 0 #f1f1f1 inset}revo-grid[theme=compact] revogr-viewport-scroll.colPinEnd{box-shadow:-1px 0 0 #f1f1f1}revo-grid[theme=compact] revogr-data .rgRow{box-shadow:0 -1px 0 0 #f1f1f1 inset}revo-grid[theme=compact] revogr-data .rgRow.focused-rgRow{background-color:rgba(233, 234, 237, 0.5)}revo-grid[theme=compact] revogr-data .rgCell{color:rgba(0, 0, 0, 0.87)}revo-grid[theme=compact] revogr-data .rgCell.disabled{background-color:#f7f7f7}revo-grid[theme=compact] revogr-data .revo-draggable>.revo-drag-icon{background-color:#d4d4d4}revo-grid[theme=compact] revogr-data .revo-draggable:hover>.revo-drag-icon{background-color:black}revo-grid[theme=compact] revo-dropdown .rv-dr-root{padding:0px 9px}revo-grid{display:block;height:100%;font-family:Helvetica, Arial, Sans-Serif, serif;font-size:14px;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:flex;flex-direction:column;width:100%;height:100%}revo-grid .footer-wrapper,revo-grid .header-wrapper{width:100%}revo-grid .footer-wrapper revogr-data,revo-grid .header-wrapper revogr-data{z-index:3}revo-grid revo-dropdown{width:100%}revo-grid revo-dropdown .rv-dr-root{max-height:100%}revo-grid revo-dropdown.shrink label{opacity:0}revo-grid .viewports{max-height:100%;display:flex;flex-direction:row;align-items:flex-start;max-width:100%}revo-grid .main-viewport{flex-grow:1;height:0;display:flex;flex-direction:row}revo-grid .draggable{position:fixed;height:30px;line-height:30px;background:#fff;border-radius:3px;display:block;z-index:100;margin-top:5px;margin-right:-20px;box-shadow:0 4px 20px 0 rgba(0, 0, 0, 0.15);padding-left:20px;padding-right:5px}revo-grid .draggable.hidden{display:none}revo-grid .draggable .revo-alt-icon{background-color:black;position:absolute;left:5px;top:10px}revo-grid .draggable-wrapper.hidden{display:none}revo-grid .drag-position{position:absolute;left:0;right:0;height:1px;z-index:2;background:gray}revo-grid .drag-position-y{position:absolute;top:0;left:0;bottom:0;width:1px;z-index:2;background:gray}revo-grid .drag-auto-scroll-y{pointer-events:none;position:absolute;left:0;top:0;height:50px;width:1px}revo-grid .clipboard{position:absolute;left:0;top:0}revo-grid revogr-scroll-virtual{position:relative}revo-grid revogr-scroll-virtual.vertical,revo-grid revogr-scroll-virtual.horizontal{z-index:3}";
2883
+
2884
+ const RevoGridComponent = class {
2885
+ constructor(hostRef) {
2886
+ registerInstance(this, hostRef);
2887
+ this.beforeedit = createEvent(this, "beforeedit", 7);
2888
+ this.beforerangeedit = createEvent(this, "beforerangeedit", 7);
2889
+ this.afteredit = createEvent(this, "afteredit", 7);
2890
+ this.beforeautofill = createEvent(this, "beforeautofill", 7);
2891
+ this.beforeaange = createEvent(this, "beforeaange", 7);
2892
+ this.roworderchanged = createEvent(this, "roworderchanged", 7);
2893
+ this.beforesourcesortingapply = createEvent(this, "beforesourcesortingapply", 7);
2894
+ this.beforesortingapply = createEvent(this, "beforesortingapply", 7);
2895
+ this.beforesorting = createEvent(this, "beforesorting", 7);
2896
+ this.rowdragstart = createEvent(this, "rowdragstart", 7);
2897
+ this.headerclick = createEvent(this, "headerclick", 7);
2898
+ this.beforecellfocus = createEvent(this, "beforecellfocus", 7);
2899
+ this.beforefocuslost = createEvent(this, "beforefocuslost", 7);
2900
+ this.beforesourceset = createEvent(this, "beforesourceset", 7);
2901
+ this.aftersourceset = createEvent(this, "aftersourceset", 7);
2902
+ this.beforecolumnsset = createEvent(this, "beforecolumnsset", 7);
2903
+ this.beforecolumnapplied = createEvent(this, "beforecolumnapplied", 7);
2904
+ this.aftercolumnsset = createEvent(this, "aftercolumnsset", 7);
2905
+ this.beforefilterapply = createEvent(this, "beforefilterapply", 7);
2906
+ this.beforefiltertrimmed = createEvent(this, "beforefiltertrimmed", 7);
2907
+ this.beforetrimmed = createEvent(this, "beforetrimmed", 7);
2908
+ this.aftertrimmed = createEvent(this, "aftertrimmed", 7);
2909
+ this.viewportscroll = createEvent(this, "viewportscroll", 7);
2910
+ this.beforeexport = createEvent(this, "beforeexport", 7);
2911
+ this.beforeeditstart = createEvent(this, "beforeeditstart", 7);
2912
+ this.aftercolumnresize = createEvent(this, "aftercolumnresize", 7);
2913
+ /**
2914
+ * Defines how many rows/columns should be rendered outside visible area.
2915
+ */
2916
+ this.frameSize = 1;
2917
+ /**
2918
+ * Indicates default rgRow size.
2919
+ * By default 0, means theme package size will be applied
2920
+ */
2921
+ this.rowSize = 0;
2922
+ /** Indicates default column size. */
2923
+ this.colSize = 100;
2924
+ /** When true, user can range selection. */
2925
+ this.range = false;
2926
+ /** When true, grid in read only mode. */
2927
+ this.readonly = false;
2928
+ /** When true, columns are resizable. */
2929
+ this.resize = false;
2930
+ /** When true cell focus appear. */
2931
+ this.canFocus = true;
2932
+ /** When true enable clipboard. */
2933
+ this.useClipboard = true;
2934
+ /**
2935
+ * Columns - defines an array of grid columns.
2936
+ * Can be column or grouped column.
2937
+ */
2938
+ this.columns = [];
2939
+ /**
2940
+ * Source - defines main data source.
2941
+ * Can be an Object or 2 dimensional array([][]);
2942
+ * Keys/indexes referenced from columns Prop
2943
+ */
2944
+ this.source = [];
2945
+ /** Pinned top Source: {[T in ColumnProp]: any} - defines pinned top rows data source. */
2946
+ this.pinnedTopSource = [];
2947
+ /** Pinned bottom Source: {[T in ColumnProp]: any} - defines pinned bottom rows data source. */
2948
+ this.pinnedBottomSource = [];
2949
+ /** Row properies applied */
2950
+ this.rowDefinitions = [];
2951
+ /** Custom editors register */
2952
+ this.editors = {};
2953
+ /** Types
2954
+ * Every type represent multiple column properties
2955
+ * Types will be merged but can be replaced with column properties
2956
+ */
2957
+ this.columnTypes = {};
2958
+ /** Theme name */
2959
+ this.theme = 'default';
2960
+ /**
2961
+ * Row class property
2962
+ * Define this property in rgRow object and this will be mapped as rgRow class
2963
+ */
2964
+ this.rowClass = '';
2965
+ /**
2966
+ * Autosize config
2967
+ * Enable columns autoSize, for more details check @autoSizeColumn plugin
2968
+ * By default disabled, hence operation is not resource efficient
2969
+ * true to enable with default params (double header separator click for autosize)
2970
+ * or provide config
2971
+ */
2972
+ this.autoSizeColumn = false;
2973
+ /**
2974
+ * Enables filter plugin
2975
+ * Can be boolean
2976
+ * Can be filter collection
2977
+ */
2978
+ this.filter = false;
2979
+ /**
2980
+ * Enables column move plugin
2981
+ * Can be boolean
2982
+ * Can be filter collection
2983
+ */
2984
+ this.canMoveColumns = false;
2985
+ /**
2986
+ * Trimmed rows
2987
+ * Functionality which allows to hide rows from main data set
2988
+ * @trimmedRows are physical rgRow indexes to hide
2989
+ */
2990
+ this.trimmedRows = {};
2991
+ /**
2992
+ * Enables export plugin
2993
+ * Can be boolean
2994
+ * Can be export options
2995
+ */
2996
+ this.exporting = false;
2997
+ /**
2998
+ * Defines stretch strategy for columns with @StretchColumn plugin
2999
+ * if there are more space on the right last column size would be increased
3000
+ */
3001
+ this.stretch = true;
3002
+ // --------------------------------------------------------------------------
3003
+ //
3004
+ // Private Properties
3005
+ //
3006
+ // --------------------------------------------------------------------------
3007
+ // for internal plugin usage
3008
+ this.extraElements = [];
3009
+ this.uuid = null;
3010
+ this.viewport = null;
3011
+ /**
3012
+ * Plugins
3013
+ * Define plugins collection
3014
+ */
3015
+ this.internalPlugins = [];
3016
+ this.subscribers = {};
3017
+ }
3018
+ // --------------------------------------------------------------------------
3019
+ //
3020
+ // Methods
3021
+ //
3022
+ // --------------------------------------------------------------------------
3023
+ /**
3024
+ * Refreshes data viewport.
3025
+ * Can be specific part as rgRow or pinned rgRow or 'all' by default.
3026
+ */
3027
+ async refresh(type = 'all') {
3028
+ this.dataProvider.refresh(type);
3029
+ }
3030
+ /** Scrolls view port to specified rgRow index */
3031
+ async scrollToRow(coordinate = 0) {
3032
+ const y = this.dimensionProvider.getViewPortPos({
3033
+ coordinate,
3034
+ dimension: 'rgRow',
3035
+ });
3036
+ await this.scrollToCoordinate({ y });
3037
+ }
3038
+ /** Scrolls view port to specified column index */
3039
+ async scrollToColumnIndex(coordinate = 0) {
3040
+ const x = this.dimensionProvider.getViewPortPos({
3041
+ coordinate,
3042
+ dimension: 'rgCol',
3043
+ });
3044
+ await this.scrollToCoordinate({ x });
3045
+ }
3046
+ /** Scrolls view port to specified column prop */
3047
+ async scrollToColumnProp(prop) {
3048
+ const coordinate = this.columnProvider.getColumnIndexByProp(prop, 'rgCol');
3049
+ if (coordinate < 0) {
3050
+ // already on the screen
3051
+ return;
3052
+ }
3053
+ const x = this.dimensionProvider.getViewPortPos({
3054
+ coordinate,
3055
+ dimension: 'rgCol',
3056
+ });
3057
+ await this.scrollToCoordinate({ x });
3058
+ }
3059
+ /** Update columns */
3060
+ async updateColumns(cols) {
3061
+ this.columnProvider.updateColumns(cols);
3062
+ }
3063
+ /** Add trimmed by type */
3064
+ async addTrimmed(trimmed, trimmedType = 'external', type = 'rgRow') {
3065
+ const event = this.beforetrimmed.emit({
3066
+ trimmed,
3067
+ trimmedType,
3068
+ type,
3069
+ });
3070
+ if (event.defaultPrevented) {
3071
+ return event;
3072
+ }
3073
+ this.dataProvider.setTrimmed({ [trimmedType]: event.detail.trimmed }, type);
3074
+ this.aftertrimmed.emit();
3075
+ return event;
3076
+ }
3077
+ /** Scrolls view port to coordinate */
3078
+ async scrollToCoordinate(cell) {
3079
+ var _a;
3080
+ (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.scrollToCell(cell);
3081
+ }
3082
+ /** Bring cell to edit mode */
3083
+ async setCellEdit(rgRow, prop, rowSource = 'rgRow') {
3084
+ var _a;
3085
+ const rgCol = ColumnDataProvider.getColumnByProp(this.columns, prop);
3086
+ if (!rgCol) {
3087
+ return;
3088
+ }
3089
+ await timeout();
3090
+ (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.setEdit(rgRow, this.columnProvider.getColumnIndexByProp(prop, 'rgCol'), rgCol.pin || 'rgCol', rowSource);
3091
+ }
3092
+ /**
3093
+ * Register new virtual node inside of grid
3094
+ * Used for additional items creation such as plugin elements
3095
+ */
3096
+ async registerVNode(elements) {
3097
+ this.extraElements.push(...elements);
3098
+ this.extraElements = [...this.extraElements];
3099
+ }
3100
+ /** Get data from source */
3101
+ async getSource(type = 'rgRow') {
3102
+ return this.dataProvider.stores[type].store.get('source');
3103
+ }
3104
+ /**
3105
+ * Get data from visible part of source
3106
+ * Trimmed/filtered rows will be excluded
3107
+ * @param type - type of source
3108
+ */
3109
+ async getVisibleSource(type = 'rgRow') {
3110
+ return getVisibleSourceItem(this.dataProvider.stores[type].store);
3111
+ }
3112
+ /**
3113
+ * Provides access to rows internal store observer
3114
+ * Can be used for plugin support
3115
+ * @param type - type of source
3116
+ */
3117
+ async getSourceStore(type = 'rgRow') {
3118
+ return this.dataProvider.stores[type].store;
3119
+ }
3120
+ /**
3121
+ * Provides access to column internal store observer
3122
+ * Can be used for plugin support
3123
+ * @param type - type of column
3124
+ */
3125
+ async getColumnStore(type = 'rgCol') {
3126
+ return this.columnProvider.stores[type].store;
3127
+ }
3128
+ /**
3129
+ * Update column sorting
3130
+ * @param column - full column details to update
3131
+ * @param index - virtual column index
3132
+ * @param order - order to apply
3133
+ */
3134
+ async updateColumnSorting(column, index, order, additive) {
3135
+ return this.columnProvider.updateColumnSorting(column, index, order, additive);
3136
+ }
3137
+ /**
3138
+ * Clears column sorting
3139
+ */
3140
+ async clearSorting() {
3141
+ this.columnProvider.clearSorting();
3142
+ }
3143
+ /**
3144
+ * Receive all columns in data source
3145
+ */
3146
+ async getColumns() {
3147
+ return this.columnProvider.getColumns();
3148
+ }
3149
+ /**
3150
+ * Clear current grid focus
3151
+ */
3152
+ async clearFocus() {
3153
+ var _a;
3154
+ const focused = await this.getFocused();
3155
+ const event = this.beforefocuslost.emit(focused);
3156
+ if (event.defaultPrevented) {
3157
+ return;
3158
+ }
3159
+ this.selectionStoreConnector.clearAll();
3160
+ (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.clearFocused();
3161
+ }
3162
+ /**
3163
+ * Get all active plugins instances
3164
+ */
3165
+ async getPlugins() {
3166
+ return [...this.internalPlugins];
3167
+ }
3168
+ /**
3169
+ * Get the currently focused cell.
3170
+ */
3171
+ async getFocused() {
3172
+ var _a;
3173
+ return (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.getFocused();
3174
+ }
3175
+ /**
3176
+ * Get the currently selected Range.
3177
+ */
3178
+ async getSelectedRange() {
3179
+ var _a;
3180
+ return (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.getSelectedRange();
3181
+ }
3182
+ // --------------------------------------------------------------------------
3183
+ //
3184
+ // Listeners outside scope
3185
+ //
3186
+ // --------------------------------------------------------------------------
3187
+ /** Clear data which is outside of grid container */
3188
+ handleOutsideClick({ target }) {
3189
+ if (!(target === null || target === void 0 ? void 0 : target.closest(`[${UUID}="${this.uuid}"]`))) {
3190
+ this.clearFocus();
3191
+ }
3192
+ }
3193
+ // --------------------------------------------------------------------------
3194
+ //
3195
+ // Listeners
3196
+ //
3197
+ // --------------------------------------------------------------------------
3198
+ /** DRAG AND DROP */
3199
+ onRowDragStarted(e) {
3200
+ var _a;
3201
+ e.cancelBubble = true;
3202
+ const dragStart = this.rowdragstart.emit(e.detail);
3203
+ if (dragStart.defaultPrevented) {
3204
+ e.preventDefault();
3205
+ return;
3206
+ }
3207
+ (_a = this.orderService) === null || _a === void 0 ? void 0 : _a.start(this.element, Object.assign(Object.assign({}, e.detail), dragStart.detail));
3208
+ }
3209
+ onRowDragEnd() {
3210
+ var _a;
3211
+ (_a = this.orderService) === null || _a === void 0 ? void 0 : _a.end();
3212
+ }
3213
+ onRowDrag({ detail }) {
3214
+ var _a;
3215
+ (_a = this.orderService) === null || _a === void 0 ? void 0 : _a.move(detail);
3216
+ }
3217
+ onRowMouseMove(e) {
3218
+ var _a;
3219
+ e.cancelBubble = true;
3220
+ (_a = this.orderService) === null || _a === void 0 ? void 0 : _a.moveTip(e.detail);
3221
+ }
3222
+ async onBeforeEdit(e) {
3223
+ e.cancelBubble = true;
3224
+ const { defaultPrevented, detail } = this.beforeedit.emit(e.detail);
3225
+ await timeout();
3226
+ // apply data
3227
+ if (!defaultPrevented) {
3228
+ this.dataProvider.setCellData(detail);
3229
+ this.afteredit.emit(detail);
3230
+ }
3231
+ }
3232
+ onBeforeRangeEdit(e) {
3233
+ e.cancelBubble = true;
3234
+ const { defaultPrevented } = this.beforerangeedit.emit(e.detail);
3235
+ if (defaultPrevented) {
3236
+ e.preventDefault();
3237
+ return;
3238
+ }
3239
+ this.afteredit.emit(e.detail);
3240
+ }
3241
+ onRangeChanged(e) {
3242
+ e.cancelBubble = true;
3243
+ const beforeaange = this.beforeaange.emit(e.detail);
3244
+ if (beforeaange.defaultPrevented) {
3245
+ e.preventDefault();
3246
+ }
3247
+ const beforeFill = this.beforeautofill.emit(e.detail);
3248
+ if (beforeFill.defaultPrevented) {
3249
+ return;
3250
+ }
3251
+ }
3252
+ onRowDropped(e) {
3253
+ e.cancelBubble = true;
3254
+ const { defaultPrevented } = this.roworderchanged.emit(e.detail);
3255
+ if (defaultPrevented) {
3256
+ e.preventDefault();
3257
+ }
3258
+ }
3259
+ onHeaderClick(e) {
3260
+ const { defaultPrevented } = this.headerclick.emit(Object.assign(Object.assign({}, e.detail.column), { originalEvent: e.detail.originalEvent }));
3261
+ if (defaultPrevented) {
3262
+ e.preventDefault();
3263
+ }
3264
+ }
3265
+ onCellFocus(e) {
3266
+ e.cancelBubble = true;
3267
+ const { defaultPrevented } = this.beforecellfocus.emit(e.detail);
3268
+ if (!this.canFocus || defaultPrevented) {
3269
+ e.preventDefault();
3270
+ }
3271
+ }
3272
+ columnChanged(newVal = []) {
3273
+ this.dimensionProvider.drop();
3274
+ const columnGather = ColumnDataProvider.getColumns(newVal, 0, this.columnTypes);
3275
+ this.beforecolumnsset.emit(columnGather);
3276
+ for (let type of columnTypes) {
3277
+ const items = columnGather.columns[type];
3278
+ this.dimensionProvider.setRealSize(items.length, type);
3279
+ this.dimensionProvider.setColumns(type, ColumnDataProvider.getSizes(items), type !== 'rgCol');
3280
+ }
3281
+ this.beforecolumnapplied.emit(columnGather);
3282
+ const columns = this.columnProvider.setColumns(columnGather);
3283
+ this.aftercolumnsset.emit({
3284
+ columns,
3285
+ order: this.columnProvider.order,
3286
+ });
3287
+ }
3288
+ themeChanged(t) {
3289
+ this.themeService.register(t);
3290
+ this.dimensionProvider.setSettings({ originItemSize: this.themeService.rowSize, frameOffset: this.frameSize || 0 }, 'rgRow');
3291
+ this.dimensionProvider.setSettings({ originItemSize: this.colSize, frameOffset: this.frameSize || 0 }, 'rgCol');
3292
+ }
3293
+ dataChanged(source = []) {
3294
+ let newSource = [...source];
3295
+ const beforesourceset = this.beforesourceset.emit({
3296
+ type: 'rgRow',
3297
+ source: newSource,
3298
+ });
3299
+ newSource = beforesourceset.detail.source;
3300
+ newSource = this.dataProvider.setData(newSource, 'rgRow');
3301
+ this.aftersourceset.emit({
3302
+ type: 'rgRow',
3303
+ source: newSource,
3304
+ });
3305
+ }
3306
+ dataBottomChanged(newVal = []) {
3307
+ this.dataProvider.setData(newVal, 'rowPinEnd');
3308
+ }
3309
+ dataTopChanged(newVal = []) {
3310
+ this.dataProvider.setData(newVal, 'rowPinStart');
3311
+ }
3312
+ rowDefChanged(newVal = []) {
3313
+ if (!newVal.length) {
3314
+ return;
3315
+ }
3316
+ const rows = reduce_1(newVal, (r, v) => {
3317
+ if (!r[v.type]) {
3318
+ r[v.type] = {};
3319
+ }
3320
+ if (v.size) {
3321
+ if (!r[v.type].sizes) {
3322
+ r[v.type].sizes = {};
3323
+ }
3324
+ r[v.type].sizes[v.index] = v.size;
3325
+ }
3326
+ return r;
3327
+ }, {});
3328
+ each(rows, (r, k) => {
3329
+ if (r.sizes) {
3330
+ this.dimensionProvider.setDimensionSize(k, r.sizes);
3331
+ }
3332
+ });
3333
+ }
3334
+ trimmedRowsChanged(newVal = {}) {
3335
+ this.addTrimmed(newVal);
3336
+ }
3337
+ groupingChanged(newVal = {}) {
3338
+ let grPlugin;
3339
+ for (let p of this.internalPlugins) {
3340
+ const isGrouping = p;
3341
+ if (isGrouping.setGrouping) {
3342
+ grPlugin = isGrouping;
3343
+ break;
3344
+ }
3345
+ }
3346
+ if (!grPlugin) {
3347
+ return;
3348
+ }
3349
+ grPlugin.setGrouping(newVal || {});
3350
+ }
3351
+ applyStretch(isStretch) {
3352
+ if (isStretch === 'false') {
3353
+ isStretch = false;
3354
+ }
3355
+ let stretch = this.internalPlugins.filter(p => isStretchPlugin(p))[0];
3356
+ if (isStretch) {
3357
+ if (!stretch) {
3358
+ this.internalPlugins.push(new StretchColumn(this.element, this.dimensionProvider));
3359
+ }
3360
+ else {
3361
+ stretch.applyStretch(this.columnProvider.getRawColumns());
3362
+ }
3363
+ }
3364
+ else if (stretch) {
3365
+ const index = this.internalPlugins.indexOf(stretch);
3366
+ this.internalPlugins.splice(index, 1);
3367
+ }
3368
+ }
3369
+ connectedCallback() {
3370
+ this.viewportProvider = new ViewportProvider();
3371
+ this.themeService = new ThemeService({
3372
+ rowSize: this.rowSize,
3373
+ });
3374
+ this.dimensionProvider = new DimensionProvider(this.viewportProvider);
3375
+ this.columnProvider = new ColumnDataProvider();
3376
+ this.dataProvider = new DataProvider(this.dimensionProvider);
3377
+ this.uuid = `${new Date().getTime()}-rvgrid`;
3378
+ const pluginData = {
3379
+ data: this.dataProvider,
3380
+ column: this.columnProvider,
3381
+ dimension: this.dimensionProvider,
3382
+ viewport: this.viewportProvider,
3383
+ selection: this.selectionStoreConnector,
3384
+ };
3385
+ if (this.autoSizeColumn) {
3386
+ this.internalPlugins.push(new AutoSizeColumn(this.element, {
3387
+ dataProvider: this.dataProvider,
3388
+ columnProvider: this.columnProvider,
3389
+ dimensionProvider: this.dimensionProvider,
3390
+ }, typeof this.autoSizeColumn === 'object' ? this.autoSizeColumn : undefined));
3391
+ }
3392
+ if (this.filter) {
3393
+ this.internalPlugins.push(new FilterPlugin(this.element, this.uuid, typeof this.filter === 'object' ? this.filter : undefined));
3394
+ }
3395
+ if (this.exporting) {
3396
+ this.internalPlugins.push(new ExportFilePlugin(this.element));
3397
+ }
3398
+ this.internalPlugins.push(new SortingPlugin(this.element));
3399
+ if (this.plugins) {
3400
+ this.plugins.forEach(p => {
3401
+ this.internalPlugins.push(new p(this.element, pluginData));
3402
+ });
3403
+ }
3404
+ if (this.canMoveColumns) {
3405
+ this.internalPlugins.push(new ColumnPlugin(this.element, pluginData));
3406
+ }
3407
+ this.internalPlugins.push(new GroupingRowPlugin(this.element, {
3408
+ dataProvider: this.dataProvider,
3409
+ columnProvider: this.columnProvider,
3410
+ }));
3411
+ this.applyStretch(this.stretch);
3412
+ this.themeChanged(this.theme);
3413
+ this.columnChanged(this.columns);
3414
+ this.dataChanged(this.source);
3415
+ this.dataTopChanged(this.pinnedTopSource);
3416
+ this.dataBottomChanged(this.pinnedBottomSource);
3417
+ this.trimmedRowsChanged(this.trimmedRows);
3418
+ this.rowDefChanged(this.rowDefinitions);
3419
+ this.groupingChanged(this.grouping);
3420
+ this.selectionStoreConnector = new SelectionStoreConnector();
3421
+ this.scrollingService = new GridScrollingService((e) => {
3422
+ this.dimensionProvider.setViewPortCoordinate({
3423
+ coordinate: e.coordinate,
3424
+ type: e.dimension,
3425
+ });
3426
+ this.viewportscroll.emit(e);
3427
+ });
3428
+ this.subscribers = { 'click': this.handleOutsideClick.bind(this) };
3429
+ for (let type in this.subscribers) {
3430
+ document.addEventListener(type, this.subscribers[type]);
3431
+ }
3432
+ }
3433
+ disconnectedCallback() {
3434
+ // destroy plugins on element disconnect
3435
+ each(this.internalPlugins, p => p.destroy());
3436
+ this.internalPlugins = [];
3437
+ // clear events
3438
+ for (let type in this.subscribers) {
3439
+ document.removeEventListener(type, this.subscribers[type]);
3440
+ delete this.subscribers[type];
3441
+ }
3442
+ }
3443
+ render() {
3444
+ const contentHeight = this.dimensionProvider.stores['rgRow'].store.get('realSize');
3445
+ this.viewport = new ViewportService({
3446
+ columnProvider: this.columnProvider,
3447
+ dataProvider: this.dataProvider,
3448
+ dimensionProvider: this.dimensionProvider,
3449
+ viewportProvider: this.viewportProvider,
3450
+ uuid: this.uuid,
3451
+ scrollingService: this.scrollingService,
3452
+ orderService: this.orderService,
3453
+ selectionStoreConnector: this.selectionStoreConnector,
3454
+ resize: c => this.aftercolumnresize.emit(c)
3455
+ }, contentHeight);
3456
+ const views = [];
3457
+ if (this.rowHeaders) {
3458
+ const anyView = this.viewport.columns[0];
3459
+ views.push(h("revogr-row-headers", { height: contentHeight, resize: this.resize, dataPorts: anyView.dataPorts, headerProp: anyView.headerProp, uiid: anyView.prop[UUID], rowHeaderColumn: typeof this.rowHeaders === 'object' ? this.rowHeaders : undefined, onScrollViewport: ({ detail: e }) => this.scrollingService.onScroll(e, 'headerRow'), onElementToScroll: ({ detail: e }) => this.scrollingService.registerElement(e, 'headerRow') }));
3460
+ }
3461
+ views.push(h(ViewPortSections, { columnFilter: !!this.filter, resize: this.resize, readonly: this.readonly, range: this.range, rowClass: this.rowClass, editors: this.editors, useClipboard: this.useClipboard, columns: this.viewport.columns, onEdit: detail => {
3462
+ const event = this.beforeeditstart.emit(detail);
3463
+ if (!event.defaultPrevented) {
3464
+ this.selectionStoreConnector.setEdit(detail.isCancel ? false : detail.val);
3465
+ }
3466
+ }, registerElement: (e, k) => this.scrollingService.registerElement(e, k), onScroll: details => this.scrollingService.onScroll(details) }));
3467
+ return (h(Host, Object.assign({}, { [`${UUID}`]: this.uuid }), h(RevoViewPort, { viewports: this.viewportProvider.stores, dimensions: this.dimensionProvider.stores, orderRef: e => (this.orderService = e), registerElement: (e, k) => this.scrollingService.registerElement(e, k), nakedClick: () => this.viewport.clearEdit(), onScroll: details => this.scrollingService.onScroll(details) }, views), this.extraElements));
3468
+ }
3469
+ get element() { return getElement(this); }
3470
+ static get watchers() { return {
3471
+ "columns": ["columnChanged"],
3472
+ "theme": ["themeChanged"],
3473
+ "source": ["dataChanged"],
3474
+ "pinnedBottomSource": ["dataBottomChanged"],
3475
+ "pinnedTopSource": ["dataTopChanged"],
3476
+ "rowDefinitions": ["rowDefChanged"],
3477
+ "trimmedRows": ["trimmedRowsChanged"],
3478
+ "grouping": ["groupingChanged"],
3479
+ "stretch": ["applyStretch"]
3480
+ }; }
3481
+ };
3482
+ RevoGridComponent.style = revoGridStyleCss;
3483
+
3484
+ export { RevoGridComponent as revo_grid };