@revolist/revogrid 3.2.4 → 3.2.5

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 (211) hide show
  1. package/custom-element/index.js +29213 -0
  2. package/custom-element/resize-observer.js +503 -0
  3. package/dist/cjs/css-shim-9f5bc84d.js +9 -0
  4. package/dist/cjs/debounce-6cea2774.js +578 -0
  5. package/dist/cjs/dom-fcb646f0.js +78 -0
  6. package/dist/{revo-grid/index-8a604c17.js → cjs/index-cb904e00.js} +208 -1444
  7. package/dist/cjs/index.cjs.js +5 -0
  8. package/dist/cjs/loader.cjs.js +38 -0
  9. package/dist/cjs/resize-observer-bf327d6a.js +507 -0
  10. package/dist/cjs/revo-grid.cjs.js +79 -0
  11. package/dist/cjs/revo-grid_11.cjs.entry.js +28297 -0
  12. package/dist/cjs/revogr-clipboard.cjs.entry.js +56 -0
  13. package/dist/cjs/revogr-filter-panel.cjs.entry.js +278 -0
  14. package/dist/collection/collection-manifest.json +25 -0
  15. package/dist/collection/components/button/button.js +7 -0
  16. package/dist/collection/components/clipboard/revogr-clipboard.js +124 -0
  17. package/dist/collection/components/data/cellRenderer.js +27 -0
  18. package/dist/{revo-grid/columnService-91e552ba.js → collection/components/data/columnService.js} +6 -8
  19. package/dist/collection/components/data/revogr-data-style.css +135 -0
  20. package/dist/collection/components/data/revogr-data.js +325 -0
  21. package/dist/collection/components/data/rowRenderer.js +9 -0
  22. package/dist/collection/components/header/headerCellRenderer.js +29 -0
  23. package/dist/collection/components/header/headerRenderer.js +48 -0
  24. package/dist/collection/components/header/revogr-header-style.css +198 -0
  25. package/dist/collection/components/header/revogr-header.js +300 -0
  26. package/dist/collection/components/order/orderRenderer.js +53 -0
  27. package/dist/collection/components/order/revogr-order-editor.js +361 -0
  28. package/dist/collection/components/order/rowOrderService.js +71 -0
  29. package/dist/collection/components/overlay/autofill.service.js +185 -0
  30. package/dist/collection/components/overlay/clipboard.service.js +42 -0
  31. package/dist/collection/components/overlay/editors/edit.utils.js +8 -0
  32. package/dist/collection/components/overlay/editors/text.js +38 -0
  33. package/dist/collection/components/overlay/keyboard.service.js +131 -0
  34. package/dist/collection/components/overlay/revogr-edit-style.css +86 -0
  35. package/dist/collection/components/overlay/revogr-edit.js +162 -0
  36. package/dist/collection/components/overlay/revogr-overlay-selection.js +729 -0
  37. package/dist/collection/components/overlay/revogr-overlay-style.css +98 -0
  38. package/dist/{revo-grid/selection.utils-a9932db6.js → collection/components/overlay/selection.utils.js} +9 -12
  39. package/dist/collection/components/revo-grid/revo-grid-style.css +544 -0
  40. package/dist/collection/components/revo-grid/revo-grid.js +2227 -0
  41. package/dist/collection/components/revo-grid/viewport.helpers.js +14 -0
  42. package/dist/collection/components/revo-grid/viewport.interfaces.js +4 -0
  43. package/dist/collection/components/revo-grid/viewport.js +21 -0
  44. package/dist/collection/components/revo-grid/viewport.resize.service.js +24 -0
  45. package/dist/collection/components/revo-grid/viewport.scrolling.service.js +63 -0
  46. package/dist/collection/components/revo-grid/viewport.section.js +31 -0
  47. package/dist/collection/components/revo-grid/viewport.service.js +212 -0
  48. package/dist/collection/components/rowHeaders/revogr-row-headers.js +213 -0
  49. package/dist/collection/components/rowHeaders/row-header-render.js +4 -0
  50. package/dist/collection/components/scroll/revogr-viewport-scroll-style.css +137 -0
  51. package/dist/collection/components/scroll/revogr-viewport-scroll.js +402 -0
  52. package/dist/collection/components/scrollable/revogr-scroll-style.css +104 -0
  53. package/dist/collection/components/scrollable/revogr-scroll-virtual.js +256 -0
  54. package/dist/collection/components/selection-focus/revogr-focus-style.css +77 -0
  55. package/dist/collection/components/selection-focus/revogr-focus.js +106 -0
  56. package/dist/collection/components/selection-temp-range/revogr-temp-range-style.css +98 -0
  57. package/dist/collection/components/selection-temp-range/revogr-temp-range.js +141 -0
  58. package/dist/{revo-grid/app-globals-7e6866ba.js → collection/global/global.js} +2 -8
  59. package/dist/collection/index.js +4 -0
  60. package/dist/collection/plugins/autoSizeColumn.js +233 -0
  61. package/dist/collection/plugins/basePlugin.js +30 -0
  62. package/dist/{revo-grid/dispatcher-891af82e.js → collection/plugins/dispatcher.js} +2 -4
  63. package/dist/collection/plugins/export/csv.js +71 -0
  64. package/dist/collection/plugins/export/export.plugin.js +168 -0
  65. package/dist/collection/plugins/export/types.js +4 -0
  66. package/dist/collection/plugins/filter/conditions/equal.js +20 -0
  67. package/dist/collection/plugins/filter/conditions/number/greaterThan.js +13 -0
  68. package/dist/collection/plugins/filter/conditions/number/greaterThanOrEqual.js +10 -0
  69. package/dist/collection/plugins/filter/conditions/number/lessThan.js +15 -0
  70. package/dist/collection/plugins/filter/conditions/number/lessThanOrEqual.js +10 -0
  71. package/dist/collection/plugins/filter/conditions/set.js +6 -0
  72. package/dist/collection/plugins/filter/conditions/string/beginswith.js +20 -0
  73. package/dist/collection/plugins/filter/conditions/string/contains.js +21 -0
  74. package/dist/{revo-grid/filter.button-74c1cd9c.js → collection/plugins/filter/filter.button.js} +10 -13
  75. package/dist/collection/plugins/filter/filter.plugin.js +259 -0
  76. package/dist/collection/plugins/filter/filter.pop.js +488 -0
  77. package/dist/collection/plugins/filter/filter.service.js +47 -0
  78. package/dist/collection/plugins/filter/filter.style.css +239 -0
  79. package/dist/collection/plugins/filter/filter.types.js +4 -0
  80. package/dist/collection/plugins/groupingColumn/columnGroupsRenderer.js +33 -0
  81. package/dist/collection/plugins/groupingColumn/grouping.col.plugin.js +39 -0
  82. package/dist/collection/plugins/groupingColumn/headerGroupRenderer.js +24 -0
  83. package/dist/collection/plugins/groupingRow/grouping.const.js +13 -0
  84. package/dist/collection/plugins/groupingRow/grouping.row.expand.service.js +79 -0
  85. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +261 -0
  86. package/dist/collection/plugins/groupingRow/grouping.row.renderer.js +32 -0
  87. package/dist/collection/plugins/groupingRow/grouping.row.types.js +4 -0
  88. package/dist/collection/plugins/groupingRow/grouping.service.js +158 -0
  89. package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js +60 -0
  90. package/dist/collection/plugins/moveColumn/columnDragPlugin.js +148 -0
  91. package/dist/collection/plugins/moveColumn/columnOrderHandler.js +63 -0
  92. package/dist/collection/plugins/sorting/sorting.plugin.js +184 -0
  93. package/dist/collection/plugins/sorting/sorting.sign.js +9 -0
  94. package/dist/collection/plugins/stretchPlugin.js +71 -0
  95. package/dist/collection/plugins/trimmed/trimmed.plugin.js +35 -0
  96. package/dist/collection/services/cell.helpers.js +10 -0
  97. package/dist/collection/services/column.data.provider.js +191 -0
  98. package/dist/collection/services/data.provider.js +50 -0
  99. package/dist/collection/services/dimension.provider.js +81 -0
  100. package/dist/{revo-grid/localScrollService-e9b73323.js → collection/services/localScrollService.js} +2 -5
  101. package/dist/collection/services/resizable.directive.js +253 -0
  102. package/dist/collection/services/selection.store.connector.js +216 -0
  103. package/dist/collection/services/viewport.provider.js +17 -0
  104. package/dist/collection/store/dataSource/data.proxy.js +37 -0
  105. package/dist/collection/store/dataSource/data.store.js +130 -0
  106. package/dist/collection/store/dimension/dimension.helpers.js +110 -0
  107. package/dist/collection/store/dimension/dimension.store.js +62 -0
  108. package/dist/collection/store/selection/selection.helpers.js +56 -0
  109. package/dist/collection/store/selection/selection.store.js +71 -0
  110. package/dist/collection/store/selection/selection.store.service.js +38 -0
  111. package/dist/collection/store/storeTypes.js +8 -0
  112. package/dist/{revo-grid/viewport.store-ffaaab6d.js → collection/store/viewPort/viewport.helpers.js} +9 -132
  113. package/dist/collection/store/viewPort/viewport.store.js +124 -0
  114. package/dist/collection/themeManager/theme.compact.js +8 -0
  115. package/dist/collection/themeManager/theme.default.js +8 -0
  116. package/dist/collection/themeManager/theme.material.js +8 -0
  117. package/dist/{revo-grid/themeService-ddaaa364.js → collection/themeManager/themeService.js} +6 -23
  118. package/dist/collection/utils/closestPolifill.js +21 -0
  119. package/dist/collection/utils/consts.js +22 -0
  120. package/dist/collection/utils/generateAlphabetHeader.js +23 -0
  121. package/dist/collection/utils/keyCodes.js +73 -0
  122. package/dist/collection/utils/keyCodes.utils.js +67 -0
  123. package/dist/collection/utils/platform.js +8 -0
  124. package/dist/collection/utils/resizeObserver.js +9 -0
  125. package/dist/collection/utils/store.utils.js +10 -0
  126. package/dist/{revo-grid/utils-2c3b3857.js → collection/utils/utils.js} +8 -10
  127. package/dist/collection/utilsExternal/generate-data.js +132 -0
  128. package/dist/esm/css-shim-e1e1ea5e.js +7 -0
  129. package/dist/esm/debounce-e4e6dd45.js +561 -0
  130. package/dist/esm/dom-21bd1807.js +76 -0
  131. package/dist/esm/index-6f753b3c.js +1796 -0
  132. package/dist/esm/index.js +3 -0
  133. package/dist/esm/loader.js +34 -0
  134. package/dist/esm/polyfills/core-js.js +11 -0
  135. package/dist/esm/polyfills/css-shim.js +1 -0
  136. package/dist/esm/polyfills/dom.js +79 -0
  137. package/dist/esm/polyfills/es5-html-element.js +1 -0
  138. package/dist/esm/polyfills/index.js +34 -0
  139. package/dist/esm/polyfills/system.js +6 -0
  140. package/dist/esm/resize-observer-00c48d78.js +503 -0
  141. package/dist/esm/revo-grid.js +77 -0
  142. package/dist/{revo-grid/lodash-a0ab4cdd.js → esm/revo-grid_11.entry.js} +25347 -14282
  143. package/dist/esm/revogr-clipboard.entry.js +52 -0
  144. package/dist/esm/revogr-filter-panel.entry.js +274 -0
  145. package/dist/esm-es5/css-shim-e1e1ea5e.js +4 -0
  146. package/dist/esm-es5/debounce-e4e6dd45.js +4 -0
  147. package/dist/esm-es5/dom-21bd1807.js +24 -0
  148. package/dist/esm-es5/index-6f753b3c.js +5 -0
  149. package/dist/esm-es5/index.js +3 -0
  150. package/dist/esm-es5/loader.js +4 -0
  151. package/dist/esm-es5/resize-observer-00c48d78.js +4 -0
  152. package/dist/esm-es5/revo-grid.js +4 -0
  153. package/dist/esm-es5/revo-grid_11.entry.js +4 -0
  154. package/dist/esm-es5/revogr-clipboard.entry.js +4 -0
  155. package/dist/esm-es5/revogr-filter-panel.entry.js +4 -0
  156. package/dist/index.cjs.js +1 -0
  157. package/dist/index.js +1 -0
  158. package/dist/revo-grid/css-shim-bcf89cc0.system.js +4 -0
  159. package/dist/revo-grid/css-shim-e1e1ea5e.js +4 -0
  160. package/dist/revo-grid/debounce-5a33c710.system.js +4 -0
  161. package/dist/revo-grid/debounce-726bdadb.js +4 -0
  162. package/dist/revo-grid/dom-21bd1807.js +5 -59
  163. package/dist/revo-grid/dom-726246e2.system.js +24 -0
  164. package/dist/revo-grid/index-f14b41a0.system.js +5 -0
  165. package/dist/revo-grid/index-f30d1de1.js +5 -0
  166. package/dist/revo-grid/index.system.js +4 -0
  167. package/dist/revo-grid/resize-observer-00c48d78.js +1 -500
  168. package/dist/revo-grid/resize-observer-8af0bc0e.system.js +4 -0
  169. package/dist/revo-grid/revo-grid.esm.js +1 -130
  170. package/dist/revo-grid/revo-grid.js +133 -0
  171. package/dist/revo-grid/revo-grid.system.js +4 -0
  172. package/dist/revo-grid/revo-grid_11.entry.js +4 -0
  173. package/dist/revo-grid/revo-grid_11.system.entry.js +4 -0
  174. package/dist/revo-grid/revogr-clipboard.entry.js +1 -49
  175. package/dist/revo-grid/revogr-clipboard.system.entry.js +4 -0
  176. package/dist/revo-grid/revogr-filter-panel.entry.js +1 -274
  177. package/dist/revo-grid/revogr-filter-panel.system.entry.js +4 -0
  178. package/loader/cdn.js +3 -1
  179. package/loader/index.cjs.js +3 -1
  180. package/loader/index.d.ts +0 -1
  181. package/loader/index.es2017.js +3 -1
  182. package/loader/index.js +3 -1
  183. package/package.json +1 -1
  184. package/dist/revo-grid/_baseIteratee-af30b221.js +0 -2070
  185. package/dist/revo-grid/consts-ef824e6f.js +0 -46
  186. package/dist/revo-grid/css-shim-5387c708.js +0 -7
  187. package/dist/revo-grid/data.store-3263fff9.js +0 -557
  188. package/dist/revo-grid/debounce-aaa4b4da.js +0 -217
  189. package/dist/revo-grid/dimension.helpers-a7944fc4.js +0 -340
  190. package/dist/revo-grid/each-0378e5a3.js +0 -180
  191. package/dist/revo-grid/identity-c8c7d3d8.js +0 -26
  192. package/dist/revo-grid/isString-a51066b5.js +0 -34
  193. package/dist/revo-grid/isSymbol-e4b5dafe.js +0 -247
  194. package/dist/revo-grid/keyCodes.utils-bd06e3ba.js +0 -299
  195. package/dist/revo-grid/keys-70b7c240.js +0 -561
  196. package/dist/revo-grid/revo-grid.entry.js +0 -3484
  197. package/dist/revo-grid/revogr-data.entry.js +0 -152
  198. package/dist/revo-grid/revogr-edit.entry.js +0 -105
  199. package/dist/revo-grid/revogr-focus.entry.js +0 -41
  200. package/dist/revo-grid/revogr-header.entry.js +0 -560
  201. package/dist/revo-grid/revogr-order-editor.entry.js +0 -175
  202. package/dist/revo-grid/revogr-overlay-selection.entry.js +0 -711
  203. package/dist/revo-grid/revogr-row-headers.entry.js +0 -73
  204. package/dist/revo-grid/revogr-scroll-virtual.entry.js +0 -114
  205. package/dist/revo-grid/revogr-temp-range.entry.js +0 -73
  206. package/dist/revo-grid/revogr-viewport-scroll.entry.js +0 -340
  207. package/dist/revo-grid/selection.store.connector-2b613fd0.js +0 -503
  208. package/dist/revo-grid/shadow-css-602a09db.js +0 -390
  209. package/dist/revo-grid/toInteger-9e6cbfd2.js +0 -107
  210. package/dist/revo-grid/toNumber-913b0b72.js +0 -105
  211. package/dist/revo-grid/viewport.helpers-49d3f031.js +0 -16
@@ -0,0 +1,63 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import { h } from '@stencil/core';
5
+ export class ColumnOrderHandler {
6
+ constructor() {
7
+ this.offset = 0;
8
+ }
9
+ renderAutoscroll(_, parent) {
10
+ if (!parent) {
11
+ return;
12
+ }
13
+ this.autoscrollEl = document.createElement('div');
14
+ this.autoscrollEl.classList.add('drag-auto-scroll-y');
15
+ parent.appendChild(this.autoscrollEl);
16
+ }
17
+ autoscroll(pos, dataContainerSize, direction = 'translateX') {
18
+ if (!this.autoscrollEl) {
19
+ return;
20
+ }
21
+ const helperOffset = 10;
22
+ // calculate current y position inside of the grid active holder
23
+ // 3 - size of element + border
24
+ const maxScroll = Math.min(pos + helperOffset, dataContainerSize - 3);
25
+ this.autoscrollEl.style.transform = `${direction}(${maxScroll}px)`;
26
+ this.autoscrollEl.scrollIntoView({
27
+ block: 'nearest',
28
+ inline: 'nearest',
29
+ });
30
+ }
31
+ start(e, { el, gridRect, elScroll }, dir = 'left') {
32
+ const scrollContainerRect = elScroll.getBoundingClientRect();
33
+ if (scrollContainerRect) {
34
+ this.offset = scrollContainerRect[dir] - gridRect[dir];
35
+ }
36
+ this.renderAutoscroll(e, el);
37
+ }
38
+ stop() {
39
+ var _a;
40
+ if (this.element) {
41
+ this.element.hidden = true;
42
+ }
43
+ (_a = this.autoscrollEl) === null || _a === void 0 ? void 0 : _a.remove();
44
+ this.autoscrollEl = undefined;
45
+ this.offset = 0;
46
+ }
47
+ showHandler(pos, size, direction = 'translateX') {
48
+ if (!this.element) {
49
+ return;
50
+ }
51
+ // do not allow overcross top of the scrollable area, header excluded
52
+ if (this.offset) {
53
+ pos = Math.max(pos, this.offset);
54
+ }
55
+ // can not be bigger then grid end
56
+ pos = Math.min(pos, size);
57
+ this.element.style.transform = `${direction}(${pos}px)`;
58
+ this.element.hidden = false;
59
+ }
60
+ render() {
61
+ return h("div", { class: "drag-position-y", hidden: true, ref: (el) => (this.element = el) });
62
+ }
63
+ }
@@ -0,0 +1,184 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import size from 'lodash/size';
5
+ import { setStore } from '../../utils/store.utils';
6
+ import ColumnDataProvider from '../../services/column.data.provider';
7
+ import BasePlugin from '../basePlugin';
8
+ /**
9
+ * lifecycle
10
+ * 1) @event beforesorting - sorting just started, nothing happened yet
11
+ * 2) @metod updateColumnSorting - column sorting icon applied to grid and column get updated, data still untiuched
12
+ * 3) @event beforesortingapply - before we applied sorting data to data source, you can prevent data apply from here
13
+ * 4) @event afterSortingApply - sorting applied, just finished event
14
+ *
15
+ * If you prevent event it'll not reach farther steps
16
+ */
17
+ export default class SortingPlugin extends BasePlugin {
18
+ constructor(revogrid) {
19
+ super(revogrid);
20
+ this.revogrid = revogrid;
21
+ this.sorting = null;
22
+ this.sortingFunc = null;
23
+ const beforesourceset = ({ detail }) => {
24
+ if (this.hasSorting) {
25
+ // is sorting allowed
26
+ const event = this.emit('beforesourcesortingapply');
27
+ // sorting prevented
28
+ if (event.defaultPrevented) {
29
+ return;
30
+ }
31
+ }
32
+ const data = this.setData(detail.source, detail.type);
33
+ if (data) {
34
+ detail.source = data;
35
+ }
36
+ };
37
+ const aftercolumnsset = async ({ detail: { order } }) => {
38
+ const columns = await this.revogrid.getColumns();
39
+ const sortingFunc = {};
40
+ for (let prop in order) {
41
+ const column = ColumnDataProvider.getColumnByProp(columns, prop);
42
+ const cmp = (column === null || column === void 0 ? void 0 : column.cellCompare) || this.defaultCellCompare;
43
+ sortingFunc[prop] = order[prop] == 'desc' ? this.descCellCompare(cmp) : cmp;
44
+ }
45
+ this.sort(order, sortingFunc);
46
+ };
47
+ const headerclick = async (e) => {
48
+ var _a, _b;
49
+ if (e.defaultPrevented) {
50
+ return;
51
+ }
52
+ if (!e.detail.column.sortable) {
53
+ return;
54
+ }
55
+ 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);
56
+ };
57
+ this.addEventListener('beforesourceset', beforesourceset);
58
+ this.addEventListener('aftercolumnsset', aftercolumnsset);
59
+ this.addEventListener('initialHeaderClick', headerclick);
60
+ }
61
+ get hasSorting() {
62
+ return !!this.sorting;
63
+ }
64
+ async headerclick(column, index, additive) {
65
+ let order = this.getNextOrder(column.order);
66
+ const beforeEvent = this.emit('beforesorting', { column, order, additive });
67
+ if (beforeEvent.defaultPrevented) {
68
+ return;
69
+ }
70
+ order = beforeEvent.detail.order;
71
+ const newCol = await this.revogrid.updateColumnSorting(beforeEvent.detail.column, index, order, additive);
72
+ // apply sort data
73
+ const beforeApplyEvent = this.emit('beforesortingapply', { column: newCol, order, additive });
74
+ if (beforeApplyEvent.defaultPrevented) {
75
+ return;
76
+ }
77
+ order = beforeApplyEvent.detail.order;
78
+ const cellCmp = (column === null || column === void 0 ? void 0 : column.cellCompare) || this.defaultCellCompare;
79
+ const cmp = order == 'asc' ? cellCmp : order == 'desc' ? this.descCellCompare(cellCmp) : undefined;
80
+ if (additive && this.sorting) {
81
+ const sorting = {};
82
+ const sortingFunc = {};
83
+ Object.assign(sorting, this.sorting);
84
+ Object.assign(sortingFunc, this.sortingFunc);
85
+ if (column.prop in sorting && size(sorting) > 1 && order === undefined) {
86
+ delete sorting[column.prop];
87
+ delete sortingFunc[column.prop];
88
+ }
89
+ else {
90
+ sorting[column.prop] = order;
91
+ sortingFunc[column.prop] = cmp;
92
+ }
93
+ this.sort(sorting, sortingFunc);
94
+ }
95
+ else {
96
+ this.sort({ [column.prop]: order }, { [column.prop]: cmp });
97
+ }
98
+ }
99
+ setData(data, type) {
100
+ // sorting available for rgRow type only
101
+ if (type === 'rgRow' && this.sortingFunc) {
102
+ return this.sortItems(data, this.sortingFunc);
103
+ }
104
+ }
105
+ /**
106
+ * Sorting apply, available for rgRow type only
107
+ * @param sorting - per column sorting
108
+ * @param data - this.stores['rgRow'].store.get('source')
109
+ */
110
+ async sort(sorting, sortingFunc) {
111
+ if (!size(sorting)) {
112
+ this.sorting = null;
113
+ this.sortingFunc = null;
114
+ return;
115
+ }
116
+ this.sorting = sorting;
117
+ this.sortingFunc = sortingFunc;
118
+ const store = await this.revogrid.getSourceStore();
119
+ const source = store.get('source');
120
+ const proxyItems = this.sortIndexByItems([...store.get('proxyItems')], source, this.sortingFunc);
121
+ setStore(store, {
122
+ proxyItems,
123
+ source: [...source],
124
+ });
125
+ this.emit('afterSortingApply');
126
+ }
127
+ defaultCellCompare(prop, a, b) {
128
+ var _a, _b;
129
+ const av = (_a = a[prop]) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
130
+ const bv = (_b = b[prop]) === null || _b === void 0 ? void 0 : _b.toString().toLowerCase();
131
+ return av == bv ? 0 : av > bv ? 1 : -1;
132
+ }
133
+ descCellCompare(cmp) {
134
+ return (prop, a, b) => { return -1 * cmp(prop, a, b); };
135
+ }
136
+ sortIndexByItems(indexes, source, sortingFunc) {
137
+ // TODO - is there a situation where multiple kvps in the `sorting` object would cause this to break?
138
+ for (let prop in sortingFunc) {
139
+ if (typeof sortingFunc[prop] === 'undefined') {
140
+ // Unsort indexes
141
+ return [...Array(indexes.length).keys()];
142
+ }
143
+ }
144
+ return indexes.sort((a, b) => {
145
+ let sorted = 0;
146
+ for (let prop in sortingFunc) {
147
+ const cmp = sortingFunc[prop];
148
+ const itemA = source[a];
149
+ const itemB = source[b];
150
+ sorted = cmp(prop, itemA, itemB);
151
+ if (sorted) {
152
+ break;
153
+ }
154
+ }
155
+ return sorted;
156
+ });
157
+ }
158
+ sortItems(source, sortingFunc) {
159
+ return source.sort((a, b) => {
160
+ let sorted = 0;
161
+ for (let prop in sortingFunc) {
162
+ const cmp = sortingFunc[prop];
163
+ if (!cmp) {
164
+ continue;
165
+ }
166
+ sorted = cmp(prop, a, b);
167
+ if (sorted) {
168
+ break;
169
+ }
170
+ }
171
+ return sorted;
172
+ });
173
+ }
174
+ getNextOrder(currentOrder) {
175
+ switch (currentOrder) {
176
+ case undefined:
177
+ return 'asc';
178
+ case 'asc':
179
+ return 'desc';
180
+ case 'desc':
181
+ return undefined;
182
+ }
183
+ }
184
+ }
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import { h } from '@stencil/core';
5
+ export const FILTER_BUTTON_CLASS = 'rv-filter';
6
+ export const FILTER_BUTTON_ACTIVE = 'active';
7
+ export const SortingSign = ({ column }) => {
8
+ return h("i", { class: column.order });
9
+ };
@@ -0,0 +1,71 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import { each } from 'lodash';
5
+ import { getScrollbarWidth } from '../utils/utils';
6
+ import BasePlugin from './basePlugin';
7
+ export default class StretchColumn extends BasePlugin {
8
+ constructor(revogrid, dimensionProvider) {
9
+ super(revogrid);
10
+ this.dimensionProvider = dimensionProvider;
11
+ this.stretchedColumn = null;
12
+ this.scrollSize = getScrollbarWidth(document);
13
+ const beforecolumnapplied = ({ detail: { columns } }) => this.applyStretch(columns);
14
+ this.addEventListener('beforecolumnapplied', beforecolumnapplied);
15
+ }
16
+ setScroll({ type, hasScroll }) {
17
+ var _a;
18
+ if (type === 'rgRow' && this.stretchedColumn && ((_a = this.stretchedColumn) === null || _a === void 0 ? void 0 : _a.initialSize) === this.stretchedColumn.size) {
19
+ if (hasScroll) {
20
+ this.stretchedColumn.size -= this.scrollSize;
21
+ this.apply();
22
+ this.dropChanges();
23
+ }
24
+ }
25
+ }
26
+ activateChanges() {
27
+ const setScroll = ({ detail }) => this.setScroll(detail);
28
+ this.addEventListener('scrollchange', setScroll);
29
+ }
30
+ dropChanges() {
31
+ this.stretchedColumn = null;
32
+ this.removeEventListener('scrollchange');
33
+ }
34
+ apply() {
35
+ if (!this.stretchedColumn) {
36
+ return;
37
+ }
38
+ const type = 'rgCol';
39
+ this.dimensionProvider.setDimensionSize(type, { [this.stretchedColumn.index]: this.stretchedColumn.size });
40
+ }
41
+ applyStretch(columns) {
42
+ this.dropChanges();
43
+ let sizeDifference = this.revogrid.clientWidth - 1;
44
+ each(columns, (_c, type) => {
45
+ const realSize = this.dimensionProvider.stores[type].store.get('realSize');
46
+ sizeDifference -= realSize;
47
+ });
48
+ if (sizeDifference > 0) {
49
+ // currently plugin accepts last column
50
+ const index = columns.rgCol.length - 1;
51
+ const last = columns.rgCol[index];
52
+ // has column
53
+ // no auto size applied
54
+ // size for column shouldn't be defined
55
+ const colSize = (last === null || last === void 0 ? void 0 : last.size) || this.revogrid.colSize || 0;
56
+ const size = sizeDifference + colSize - 1;
57
+ if (last && !last.autoSize && (colSize < size)) {
58
+ this.stretchedColumn = {
59
+ initialSize: size,
60
+ index,
61
+ size
62
+ };
63
+ this.apply();
64
+ this.activateChanges();
65
+ }
66
+ }
67
+ }
68
+ }
69
+ export function isStretchPlugin(plugin) {
70
+ return !!plugin.applyStretch;
71
+ }
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ /**
5
+ * Hide items from main collection
6
+ * But keep them in store
7
+ */
8
+ export const trimmedPlugin = (store) => ({
9
+ set(k, newVal) {
10
+ switch (k) {
11
+ case 'trimmed':
12
+ const proxy = store.get('proxyItems');
13
+ const trimmed = gatherTrimmedItems(newVal);
14
+ const newItems = proxy.reduce((result, v) => {
15
+ // check if present in new trimmed remove from items (filter)
16
+ if (!trimmed[v]) {
17
+ result.push(v);
18
+ }
19
+ return result;
20
+ }, []);
21
+ store.set('items', newItems);
22
+ break;
23
+ }
24
+ },
25
+ });
26
+ export function gatherTrimmedItems(trimmedItems) {
27
+ const trimmed = {};
28
+ for (let trimmedKey in trimmedItems) {
29
+ // trimmed overweight not trimmed
30
+ for (let t in trimmedItems[trimmedKey]) {
31
+ trimmed[t] = trimmed[t] || trimmedItems[trimmedKey][t];
32
+ }
33
+ }
34
+ return trimmed;
35
+ }
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import { DATA_COL, DATA_ROW } from '../utils/consts';
5
+ export function getCell(cell) {
6
+ return {
7
+ x: parseInt(cell.getAttribute(DATA_COL), 10),
8
+ y: parseInt(cell.getAttribute(DATA_ROW), 10),
9
+ };
10
+ }
@@ -0,0 +1,191 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import reduce from 'lodash/reduce';
5
+ import each from 'lodash/each';
6
+ import find from 'lodash/find';
7
+ import DataStore, { getSourceItem, getSourceItemVirtualIndexByProp, setSourceByVirtualIndex } from '../store/dataSource/data.store';
8
+ import { columnTypes } from '../store/storeTypes';
9
+ import GroupingColumnPlugin from '../plugins/groupingColumn/grouping.col.plugin';
10
+ export default class ColumnDataProvider {
11
+ constructor() {
12
+ this.sorting = null;
13
+ this.dataSources = reduce(columnTypes, (sources, k) => {
14
+ sources[k] = new DataStore(k);
15
+ return sources;
16
+ }, {});
17
+ }
18
+ get order() {
19
+ return reduce(this.sorting, (r, c, prop) => {
20
+ r[prop] = c.order;
21
+ return r;
22
+ }, {});
23
+ }
24
+ get stores() {
25
+ return this.dataSources;
26
+ }
27
+ column(c, pin) {
28
+ return this.getColumn(c, pin || 'rgCol');
29
+ }
30
+ getColumn(virtualIndex, type) {
31
+ return getSourceItem(this.dataSources[type].store, virtualIndex);
32
+ }
33
+ getRawColumns() {
34
+ return reduce(this.dataSources, (result, item, type) => {
35
+ result[type] = item.store.get('source');
36
+ return result;
37
+ }, {
38
+ rgCol: [],
39
+ colPinStart: [],
40
+ colPinEnd: []
41
+ });
42
+ }
43
+ getColumns(type = 'all') {
44
+ if (type !== 'all') {
45
+ return this.dataSources[type].store.get('source');
46
+ }
47
+ return columnTypes.reduce((r, t) => {
48
+ r.push(...this.dataSources[t].store.get('source'));
49
+ return r;
50
+ }, []);
51
+ }
52
+ getColumnIndexByProp(prop, type) {
53
+ return getSourceItemVirtualIndexByProp(this.dataSources[type].store, prop);
54
+ }
55
+ getColumnByProp(prop, type) {
56
+ const items = this.dataSources[type].store.get('source');
57
+ return find(items, { prop });
58
+ }
59
+ refreshByType(type) {
60
+ this.dataSources[type].refresh();
61
+ }
62
+ setColumns(data) {
63
+ each(columnTypes, k => {
64
+ // set columns data
65
+ this.dataSources[k].updateData(data.columns[k], {
66
+ // max depth level
67
+ depth: data.maxLevel,
68
+ // groups
69
+ groups: reduce(data.columnGrouping[k], (res, g) => {
70
+ if (!res[g.level]) {
71
+ res[g.level] = [];
72
+ }
73
+ res[g.level].push(g);
74
+ return res;
75
+ }, {}),
76
+ });
77
+ });
78
+ this.sorting = data.sort;
79
+ return data;
80
+ }
81
+ updateColumns(cols) {
82
+ // collect column by type and propert
83
+ const columnByKey = cols.reduce((res, c) => {
84
+ const type = ColumnDataProvider.getColumnType(c);
85
+ if (!res[type]) {
86
+ res[type] = {};
87
+ }
88
+ res[type][c.prop] = c;
89
+ return res;
90
+ }, {});
91
+ // find indexes in source
92
+ const colByIndex = {};
93
+ each(columnByKey, (colsToUpdate, type) => {
94
+ const items = this.dataSources[type].store.get('source');
95
+ colByIndex[type] = items.reduce((result, rgCol, index) => {
96
+ const colToUpdateIfExists = colsToUpdate[rgCol.prop];
97
+ if (colToUpdateIfExists) {
98
+ result[index] = colToUpdateIfExists;
99
+ }
100
+ return result;
101
+ }, {});
102
+ });
103
+ each(colByIndex, (colsToUpdate, type) => setSourceByVirtualIndex(this.dataSources[type].store, colsToUpdate));
104
+ }
105
+ updateColumn(column, index) {
106
+ const type = ColumnDataProvider.getColumnType(column);
107
+ setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });
108
+ }
109
+ updateColumnSorting(column, index, sorting, additive) {
110
+ if (!additive) {
111
+ this.clearSorting();
112
+ }
113
+ column.order = sorting;
114
+ this.sorting[column.prop] = column;
115
+ this.updateColumn(column, index);
116
+ return column;
117
+ }
118
+ clearSorting() {
119
+ const types = reduce(this.sorting, (r, c) => {
120
+ const k = ColumnDataProvider.getColumnType(c);
121
+ r[k] = true;
122
+ return r;
123
+ }, {});
124
+ each(types, (_, type) => {
125
+ const cols = this.dataSources[type].store.get('source');
126
+ each(cols, (c) => (c.order = undefined));
127
+ this.dataSources[type].setData({ source: [...cols] });
128
+ });
129
+ this.sorting = {};
130
+ }
131
+ static getSizes(cols) {
132
+ return reduce(cols, (res, c, i) => {
133
+ if (c.size) {
134
+ res[i] = c.size;
135
+ }
136
+ return res;
137
+ }, {});
138
+ }
139
+ static getColumnByProp(columns, prop) {
140
+ return find(columns, c => {
141
+ if (GroupingColumnPlugin.isColGrouping(c)) {
142
+ return ColumnDataProvider.getColumnByProp(c.children, prop);
143
+ }
144
+ return c.prop === prop;
145
+ });
146
+ }
147
+ // columns processing
148
+ static getColumns(columns, level = 0, types) {
149
+ return reduce(columns, (res, colData) => {
150
+ /** Grouped column */
151
+ if (GroupingColumnPlugin.isColGrouping(colData)) {
152
+ return GroupingColumnPlugin.gatherGroup(res, colData, ColumnDataProvider.getColumns(colData.children, level + 1, types), level);
153
+ }
154
+ /** Regular column */
155
+ const regularColumn = Object.assign(Object.assign({}, (colData.columnType && types && types[colData.columnType])), colData);
156
+ // not pin
157
+ if (!regularColumn.pin) {
158
+ res.columns.rgCol.push(regularColumn);
159
+ // pin
160
+ }
161
+ else {
162
+ res.columns[regularColumn.pin].push(regularColumn);
163
+ }
164
+ if (regularColumn.order) {
165
+ res.sort[regularColumn.prop] = regularColumn;
166
+ }
167
+ // trigger setup hook if present
168
+ regularColumn.beforeSetup && regularColumn.beforeSetup(regularColumn);
169
+ return res;
170
+ }, {
171
+ columns: {
172
+ rgCol: [],
173
+ colPinStart: [],
174
+ colPinEnd: [],
175
+ },
176
+ columnGrouping: {
177
+ rgCol: [],
178
+ colPinStart: [],
179
+ colPinEnd: [],
180
+ },
181
+ maxLevel: level,
182
+ sort: {},
183
+ });
184
+ }
185
+ static getColumnType(rgCol) {
186
+ if (rgCol.pin) {
187
+ return rgCol.pin;
188
+ }
189
+ return 'rgCol';
190
+ }
191
+ }
@@ -0,0 +1,50 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import reduce from 'lodash/reduce';
5
+ import DataStore, { getSourceItem, getVisibleSourceItem, setSourceByVirtualIndex } from '../store/dataSource/data.store';
6
+ import { isRowType, rowTypes } from '../store/storeTypes';
7
+ export class DataProvider {
8
+ constructor(dimensionProvider) {
9
+ this.dimensionProvider = dimensionProvider;
10
+ this.stores = reduce(rowTypes, (sources, k) => {
11
+ sources[k] = new DataStore(k);
12
+ return sources;
13
+ }, {});
14
+ }
15
+ setData(data, type = 'rgRow', grouping, silent = false) {
16
+ // set rgRow data
17
+ this.stores[type].updateData([...data], grouping, silent);
18
+ this.dimensionProvider.setData(data, type, type !== 'rgRow');
19
+ return data;
20
+ }
21
+ getModel(virtualIndex, type = 'rgRow') {
22
+ const store = this.stores[type].store;
23
+ return getSourceItem(store, virtualIndex);
24
+ }
25
+ setCellData({ type, rowIndex, prop, val }) {
26
+ const model = this.getModel(rowIndex, type);
27
+ model[prop] = val;
28
+ setSourceByVirtualIndex(this.stores[type].store, { [rowIndex]: model });
29
+ }
30
+ refresh(type = 'all') {
31
+ if (isRowType(type)) {
32
+ this.refreshItems(type);
33
+ }
34
+ rowTypes.forEach((t) => this.refreshItems(t));
35
+ }
36
+ refreshItems(type = 'rgRow') {
37
+ const items = this.stores[type].store.get('items');
38
+ this.stores[type].setData({ items: [...items] });
39
+ }
40
+ setGrouping({ depth }, type = 'rgRow') {
41
+ this.stores[type].setData({ groupingDepth: depth });
42
+ }
43
+ setTrimmed(trimmed, type = 'rgRow') {
44
+ const store = this.stores[type];
45
+ store.addTrimmed(trimmed);
46
+ if (type === 'rgRow') {
47
+ this.dimensionProvider.setData(getVisibleSourceItem(store.store), type);
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,81 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import reduce from 'lodash/reduce';
5
+ import { columnTypes, rowTypes } from '../store/storeTypes';
6
+ import DimensionStore from '../store/dimension/dimension.store';
7
+ import { getItemByIndex } from '../store/dimension/dimension.helpers';
8
+ export default class DimensionProvider {
9
+ constructor(viewports) {
10
+ this.viewports = viewports;
11
+ this.stores = reduce([...rowTypes, ...columnTypes], (sources, k) => {
12
+ sources[k] = new DimensionStore();
13
+ return sources;
14
+ }, {});
15
+ }
16
+ setDimensionSize(dimensionType, sizes) {
17
+ this.stores[dimensionType].setDimensionSize(sizes);
18
+ this.viewports.stores[dimensionType].setViewPortDimension(sizes);
19
+ }
20
+ setRealSize(realCount, type) {
21
+ this.viewports.stores[type].setViewport({ realCount });
22
+ this.stores[type].setRealSize(realCount);
23
+ }
24
+ /**
25
+ * Sets dimension data and view port coordinate
26
+ * @param items - data/column items
27
+ * @param type - dimension type
28
+ */
29
+ setData(items, type, noVirtual = false) {
30
+ this.setRealSize(items.length, type);
31
+ if (noVirtual) {
32
+ this.setNoVirtual(type);
33
+ }
34
+ this.setViewPortCoordinate({
35
+ coordinate: this.viewports.stores[type].store.get('lastCoordinate'),
36
+ type,
37
+ });
38
+ }
39
+ setNoVirtual(type) {
40
+ const dimension = this.stores[type].getCurrentState();
41
+ this.viewports.stores[type].setViewport({ virtualSize: dimension.realSize });
42
+ }
43
+ drop() {
44
+ for (let type of columnTypes) {
45
+ this.stores[type].drop();
46
+ }
47
+ }
48
+ setColumns(type, sizes, noVirtual = false) {
49
+ this.stores[type].setDimensionSize(sizes);
50
+ if (noVirtual) {
51
+ this.setNoVirtual(type);
52
+ }
53
+ this.setViewPortCoordinate({
54
+ coordinate: this.viewports.stores[type].store.get('lastCoordinate'),
55
+ type,
56
+ });
57
+ }
58
+ setViewPortCoordinate({ coordinate, type }) {
59
+ const dimension = this.stores[type].getCurrentState();
60
+ this.viewports.stores[type].setViewPortCoordinate(coordinate, dimension);
61
+ }
62
+ getViewPortPos(e) {
63
+ const dimension = this.stores[e.dimension].getCurrentState();
64
+ const item = getItemByIndex(dimension, e.coordinate);
65
+ return item.start;
66
+ }
67
+ setSettings(data, dimensionType) {
68
+ let stores = [];
69
+ switch (dimensionType) {
70
+ case 'rgCol':
71
+ stores = columnTypes;
72
+ break;
73
+ case 'rgRow':
74
+ stores = rowTypes;
75
+ break;
76
+ }
77
+ for (let s of stores) {
78
+ this.stores[s].setStore(data);
79
+ }
80
+ }
81
+ }