@revolist/revogrid 3.2.0 → 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 (210) 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/{collection/plugins/dispatcher.js → revo-grid/dispatcher-891af82e.js} +7 -2
  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 -24835
  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.d.ts +100 -56
  47. package/dist/types/stencil-public-runtime.d.ts +189 -186
  48. package/package.json +22 -20
  49. package/custom-element/index.js +0 -29210
  50. package/custom-element/resize-observer.js +0 -489
  51. package/dist/cjs/css-shim-e33df79c.js +0 -6
  52. package/dist/cjs/debounce-e9b040d9.js +0 -575
  53. package/dist/cjs/index-d3f67f2e.js +0 -1729
  54. package/dist/cjs/index.cjs.js +0 -2
  55. package/dist/cjs/loader.cjs.js +0 -35
  56. package/dist/cjs/revo-grid.cjs.js +0 -73
  57. package/dist/cjs/revo-grid_11.cjs.entry.js +0 -28294
  58. package/dist/cjs/revogr-clipboard.cjs.entry.js +0 -53
  59. package/dist/cjs/revogr-filter-panel.cjs.entry.js +0 -275
  60. package/dist/collection/collection-manifest.json +0 -25
  61. package/dist/collection/components/button/button.js +0 -4
  62. package/dist/collection/components/clipboard/revogr-clipboard.js +0 -121
  63. package/dist/collection/components/data/cellRenderer.js +0 -24
  64. package/dist/collection/components/data/revogr-data-style.css +0 -135
  65. package/dist/collection/components/data/revogr-data.js +0 -322
  66. package/dist/collection/components/data/rowRenderer.js +0 -6
  67. package/dist/collection/components/header/headerCellRenderer.js +0 -26
  68. package/dist/collection/components/header/headerRenderer.js +0 -45
  69. package/dist/collection/components/header/revogr-header-style.css +0 -198
  70. package/dist/collection/components/header/revogr-header.js +0 -297
  71. package/dist/collection/components/order/orderRenderer.js +0 -50
  72. package/dist/collection/components/order/revogr-order-editor.js +0 -358
  73. package/dist/collection/components/order/rowOrderService.js +0 -68
  74. package/dist/collection/components/overlay/autofill.service.js +0 -182
  75. package/dist/collection/components/overlay/clipboard.service.js +0 -39
  76. package/dist/collection/components/overlay/editors/edit.utils.js +0 -5
  77. package/dist/collection/components/overlay/editors/text.js +0 -35
  78. package/dist/collection/components/overlay/keyboard.service.js +0 -128
  79. package/dist/collection/components/overlay/revogr-edit-style.css +0 -86
  80. package/dist/collection/components/overlay/revogr-edit.js +0 -159
  81. package/dist/collection/components/overlay/revogr-overlay-selection.js +0 -726
  82. package/dist/collection/components/overlay/revogr-overlay-style.css +0 -98
  83. package/dist/collection/components/revo-grid/revo-grid-style.css +0 -544
  84. package/dist/collection/components/revo-grid/revo-grid.js +0 -2224
  85. package/dist/collection/components/revo-grid/viewport.helpers.js +0 -11
  86. package/dist/collection/components/revo-grid/viewport.interfaces.js +0 -1
  87. package/dist/collection/components/revo-grid/viewport.js +0 -18
  88. package/dist/collection/components/revo-grid/viewport.resize.service.js +0 -21
  89. package/dist/collection/components/revo-grid/viewport.scrolling.service.js +0 -60
  90. package/dist/collection/components/revo-grid/viewport.section.js +0 -28
  91. package/dist/collection/components/revo-grid/viewport.service.js +0 -209
  92. package/dist/collection/components/rowHeaders/revogr-row-headers.js +0 -210
  93. package/dist/collection/components/rowHeaders/row-header-render.js +0 -1
  94. package/dist/collection/components/scroll/revogr-viewport-scroll-style.css +0 -137
  95. package/dist/collection/components/scroll/revogr-viewport-scroll.js +0 -399
  96. package/dist/collection/components/scrollable/revogr-scroll-style.css +0 -104
  97. package/dist/collection/components/scrollable/revogr-scroll-virtual.js +0 -253
  98. package/dist/collection/components/selection-focus/revogr-focus-style.css +0 -77
  99. package/dist/collection/components/selection-focus/revogr-focus.js +0 -103
  100. package/dist/collection/components/selection-temp-range/revogr-temp-range-style.css +0 -98
  101. package/dist/collection/components/selection-temp-range/revogr-temp-range.js +0 -138
  102. package/dist/collection/index.js +0 -1
  103. package/dist/collection/plugins/autoSizeColumn.js +0 -230
  104. package/dist/collection/plugins/basePlugin.js +0 -27
  105. package/dist/collection/plugins/export/csv.js +0 -68
  106. package/dist/collection/plugins/export/export.plugin.js +0 -165
  107. package/dist/collection/plugins/export/types.js +0 -1
  108. package/dist/collection/plugins/filter/conditions/equal.js +0 -17
  109. package/dist/collection/plugins/filter/conditions/number/greaterThan.js +0 -10
  110. package/dist/collection/plugins/filter/conditions/number/greaterThanOrEqual.js +0 -7
  111. package/dist/collection/plugins/filter/conditions/number/lessThan.js +0 -12
  112. package/dist/collection/plugins/filter/conditions/number/lessThanOrEqual.js +0 -7
  113. package/dist/collection/plugins/filter/conditions/set.js +0 -3
  114. package/dist/collection/plugins/filter/conditions/string/beginswith.js +0 -17
  115. package/dist/collection/plugins/filter/conditions/string/contains.js +0 -18
  116. package/dist/collection/plugins/filter/filter.plugin.js +0 -256
  117. package/dist/collection/plugins/filter/filter.pop.js +0 -485
  118. package/dist/collection/plugins/filter/filter.service.js +0 -44
  119. package/dist/collection/plugins/filter/filter.style.css +0 -239
  120. package/dist/collection/plugins/filter/filter.types.js +0 -1
  121. package/dist/collection/plugins/groupingColumn/columnGroupsRenderer.js +0 -30
  122. package/dist/collection/plugins/groupingColumn/grouping.col.plugin.js +0 -36
  123. package/dist/collection/plugins/groupingColumn/headerGroupRenderer.js +0 -21
  124. package/dist/collection/plugins/groupingRow/grouping.const.js +0 -10
  125. package/dist/collection/plugins/groupingRow/grouping.row.expand.service.js +0 -76
  126. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +0 -258
  127. package/dist/collection/plugins/groupingRow/grouping.row.renderer.js +0 -29
  128. package/dist/collection/plugins/groupingRow/grouping.row.types.js +0 -1
  129. package/dist/collection/plugins/groupingRow/grouping.service.js +0 -155
  130. package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js +0 -57
  131. package/dist/collection/plugins/moveColumn/columnDragPlugin.js +0 -145
  132. package/dist/collection/plugins/moveColumn/columnOrderHandler.js +0 -60
  133. package/dist/collection/plugins/sorting/sorting.plugin.js +0 -181
  134. package/dist/collection/plugins/sorting/sorting.sign.js +0 -6
  135. package/dist/collection/plugins/stretchPlugin.js +0 -68
  136. package/dist/collection/plugins/trimmed/trimmed.plugin.js +0 -32
  137. package/dist/collection/services/cell.helpers.js +0 -7
  138. package/dist/collection/services/column.data.provider.js +0 -188
  139. package/dist/collection/services/data.provider.js +0 -47
  140. package/dist/collection/services/dimension.provider.js +0 -78
  141. package/dist/collection/services/resizable.directive.js +0 -250
  142. package/dist/collection/services/selection.store.connector.js +0 -213
  143. package/dist/collection/services/viewport.provider.js +0 -14
  144. package/dist/collection/store/dataSource/data.proxy.js +0 -34
  145. package/dist/collection/store/dataSource/data.store.js +0 -127
  146. package/dist/collection/store/dimension/dimension.helpers.js +0 -107
  147. package/dist/collection/store/dimension/dimension.store.js +0 -59
  148. package/dist/collection/store/selection/selection.helpers.js +0 -53
  149. package/dist/collection/store/selection/selection.store.js +0 -68
  150. package/dist/collection/store/selection/selection.store.service.js +0 -35
  151. package/dist/collection/store/storeTypes.js +0 -5
  152. package/dist/collection/store/viewPort/viewport.store.js +0 -121
  153. package/dist/collection/themeManager/theme.compact.js +0 -5
  154. package/dist/collection/themeManager/theme.default.js +0 -5
  155. package/dist/collection/themeManager/theme.material.js +0 -5
  156. package/dist/collection/utils/closestPolifill.js +0 -18
  157. package/dist/collection/utils/consts.js +0 -19
  158. package/dist/collection/utils/generateAlphabetHeader.js +0 -20
  159. package/dist/collection/utils/keyCodes.js +0 -70
  160. package/dist/collection/utils/keyCodes.utils.js +0 -64
  161. package/dist/collection/utils/platform.js +0 -5
  162. package/dist/collection/utils/resizeObserver.js +0 -6
  163. package/dist/collection/utils/store.utils.js +0 -7
  164. package/dist/collection/utilsExternal/generate-data.js +0 -132
  165. package/dist/esm/css-shim-8d75038b.js +0 -4
  166. package/dist/esm/debounce-45985ae0.js +0 -558
  167. package/dist/esm/dom-1b195079.js +0 -73
  168. package/dist/esm/index-42c84e7c.js +0 -1694
  169. package/dist/esm/index.js +0 -1
  170. package/dist/esm/loader.js +0 -31
  171. package/dist/esm/polyfills/core-js.js +0 -11
  172. package/dist/esm/polyfills/css-shim.js +0 -1
  173. package/dist/esm/polyfills/dom.js +0 -79
  174. package/dist/esm/polyfills/es5-html-element.js +0 -1
  175. package/dist/esm/polyfills/index.js +0 -34
  176. package/dist/esm/polyfills/system.js +0 -6
  177. package/dist/esm/resize-observer-56b7b34f.js +0 -489
  178. package/dist/esm/revo-grid.js +0 -71
  179. package/dist/esm/revogr-clipboard.entry.js +0 -49
  180. package/dist/esm/revogr-filter-panel.entry.js +0 -271
  181. package/dist/esm-es5/css-shim-8d75038b.js +0 -1
  182. package/dist/esm-es5/debounce-45985ae0.js +0 -1
  183. package/dist/esm-es5/dom-1b195079.js +0 -21
  184. package/dist/esm-es5/index-42c84e7c.js +0 -1
  185. package/dist/esm-es5/index.js +0 -0
  186. package/dist/esm-es5/loader.js +0 -1
  187. package/dist/esm-es5/resize-observer-56b7b34f.js +0 -1
  188. package/dist/esm-es5/revo-grid.js +0 -1
  189. package/dist/esm-es5/revo-grid_11.entry.js +0 -1
  190. package/dist/esm-es5/revogr-clipboard.entry.js +0 -1
  191. package/dist/esm-es5/revogr-filter-panel.entry.js +0 -1
  192. package/dist/index.cjs.js +0 -1
  193. package/dist/index.js +0 -1
  194. package/dist/revo-grid/css-shim-88bfb262.system.js +0 -1
  195. package/dist/revo-grid/css-shim-8d75038b.js +0 -1
  196. package/dist/revo-grid/debounce-6c911037.js +0 -1
  197. package/dist/revo-grid/debounce-a345f98e.system.js +0 -1
  198. package/dist/revo-grid/dom-1b195079.js +0 -19
  199. package/dist/revo-grid/dom-ee2dd1b3.system.js +0 -21
  200. package/dist/revo-grid/index-a15e7527.system.js +0 -1
  201. package/dist/revo-grid/index-a7f99799.js +0 -1
  202. package/dist/revo-grid/index.system.js +0 -1
  203. package/dist/revo-grid/resize-observer-56b7b34f.js +0 -1
  204. package/dist/revo-grid/resize-observer-7a7b9757.system.js +0 -1
  205. package/dist/revo-grid/revo-grid.js +0 -132
  206. package/dist/revo-grid/revo-grid.system.js +0 -1
  207. package/dist/revo-grid/revo-grid_11.entry.js +0 -1
  208. package/dist/revo-grid/revo-grid_11.system.entry.js +0 -1
  209. package/dist/revo-grid/revogr-clipboard.system.entry.js +0 -1
  210. package/dist/revo-grid/revogr-filter-panel.system.entry.js +0 -1
@@ -1,213 +0,0 @@
1
- import { cropCellToMax, isHiddenStore, nextCell } from '../store/selection/selection.helpers';
2
- import { SelectionStore } from '../store/selection/selection.store';
3
- export const EMPTY_INDEX = -1;
4
- export default class SelectionStoreConnector {
5
- constructor() {
6
- // dirty flag required to cleanup whole store in case visibility of panels changed
7
- this.dirty = false;
8
- this.stores = {};
9
- this.columnStores = {};
10
- this.rowStores = {};
11
- this.sections = [];
12
- }
13
- get focusedStore() {
14
- var _a;
15
- for (let y in this.stores) {
16
- for (let x in this.stores[y]) {
17
- const focused = (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.store.get('focus');
18
- if (focused) {
19
- return {
20
- entity: this.stores[y][x],
21
- cell: focused,
22
- position: {
23
- x: parseInt(x, 10),
24
- y: parseInt(y, 10)
25
- }
26
- };
27
- }
28
- }
29
- }
30
- return null;
31
- }
32
- get edit() {
33
- var _a;
34
- return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('edit');
35
- }
36
- get focused() {
37
- var _a;
38
- return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('focus');
39
- }
40
- get selectedRange() {
41
- var _a;
42
- return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('range');
43
- }
44
- registerSection(e) {
45
- if (!e) {
46
- this.sections.length = 0;
47
- // some elements removed, rebuild stores
48
- this.dirty = true;
49
- return;
50
- }
51
- if (this.sections.indexOf(e) === -1) {
52
- this.sections.push(e);
53
- }
54
- }
55
- // check if require to cleanup all stores
56
- beforeUpdate() {
57
- if (this.dirty) {
58
- for (let y in this.stores) {
59
- for (let x in this.stores[y]) {
60
- this.stores[y][x].dispose();
61
- }
62
- }
63
- this.dirty = false;
64
- }
65
- }
66
- registerColumn(x) {
67
- // if hidden just create store
68
- if (isHiddenStore(x)) {
69
- return new SelectionStore();
70
- }
71
- if (this.columnStores[x]) {
72
- return this.columnStores[x];
73
- }
74
- this.columnStores[x] = new SelectionStore();
75
- return this.columnStores[x];
76
- }
77
- registerRow(y) {
78
- // if hidden just create store
79
- if (isHiddenStore(y)) {
80
- return new SelectionStore();
81
- }
82
- if (this.rowStores[y]) {
83
- return this.rowStores[y];
84
- }
85
- this.rowStores[y] = new SelectionStore();
86
- return this.rowStores[y];
87
- }
88
- /**
89
- * Cross store proxy, based on multiple dimensions
90
- */
91
- register({ x, y }) {
92
- var _a, _b;
93
- // if hidden just create store
94
- if (isHiddenStore(x) || isHiddenStore(y)) {
95
- return new SelectionStore();
96
- }
97
- if (!this.stores[y]) {
98
- this.stores[y] = {};
99
- }
100
- if (this.stores[y][x]) {
101
- // Store already registered. Do not register twice
102
- return this.stores[y][x];
103
- }
104
- this.stores[y][x] = new SelectionStore();
105
- // proxy update
106
- (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.onChange('range', c => {
107
- this.columnStores[x].setRangeArea(c);
108
- this.rowStores[y].setRangeArea(c);
109
- });
110
- // clean up on remove
111
- (_b = this.stores[y][x]) === null || _b === void 0 ? void 0 : _b.store.on('dispose', () => {
112
- var _a, _b;
113
- (_a = this.columnStores[x]) === null || _a === void 0 ? void 0 : _a.dispose();
114
- (_b = this.rowStores[y]) === null || _b === void 0 ? void 0 : _b.dispose();
115
- delete this.rowStores[y];
116
- delete this.columnStores[x];
117
- if (this.stores[y]) {
118
- delete this.stores[y][x];
119
- }
120
- // clear empty rows
121
- if (!Object.keys(this.stores[y] || {}).length) {
122
- delete this.stores[y];
123
- }
124
- });
125
- return this.stores[y][x];
126
- }
127
- setEditByCell({ x, y }, editCell) {
128
- const store = this.stores[y][x];
129
- this.focus(store, { focus: editCell, end: editCell });
130
- this.setEdit('');
131
- }
132
- focus(store, { focus, end }) {
133
- let currentStorePointer;
134
- // clear all stores focus leave only active one
135
- for (let y in this.stores) {
136
- for (let x in this.stores[y]) {
137
- const s = this.stores[y][x];
138
- // clear other stores, only one area can be selected
139
- if (s !== store) {
140
- s.clearFocus();
141
- }
142
- else {
143
- currentStorePointer = { x: parseInt(x, 10), y: parseInt(y, 10) };
144
- }
145
- }
146
- }
147
- if (!currentStorePointer) {
148
- return;
149
- }
150
- // check is focus in next store
151
- const lastCell = store.store.get('lastCell');
152
- // item in new store
153
- const nextItem = nextCell(focus, lastCell);
154
- let nextStore;
155
- if (nextItem) {
156
- for (let i in nextItem) {
157
- let type = i;
158
- let stores;
159
- switch (type) {
160
- case 'x':
161
- stores = this.getXStores(currentStorePointer.y);
162
- break;
163
- case 'y':
164
- stores = this.getYStores(currentStorePointer.x);
165
- break;
166
- }
167
- if (nextItem[type] >= 0) {
168
- nextStore = stores[++currentStorePointer[type]];
169
- }
170
- else {
171
- nextStore = stores[--currentStorePointer[type]];
172
- const nextLastCell = nextStore === null || nextStore === void 0 ? void 0 : nextStore.store.get('lastCell');
173
- if (nextLastCell) {
174
- nextItem[type] = nextLastCell[type] + nextItem[type];
175
- }
176
- }
177
- }
178
- }
179
- // if next store present - update
180
- if (nextStore) {
181
- let item = Object.assign(Object.assign({}, focus), nextItem);
182
- this.focus(nextStore, { focus: item, end: item });
183
- return;
184
- }
185
- focus = cropCellToMax(focus, lastCell);
186
- end = cropCellToMax(focus, lastCell);
187
- store.setFocus(focus, end);
188
- }
189
- clearAll() {
190
- var _a;
191
- for (let y in this.stores) {
192
- for (let x in this.stores[y]) {
193
- (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.clearFocus();
194
- }
195
- }
196
- }
197
- setEdit(val) {
198
- if (!this.focusedStore) {
199
- return;
200
- }
201
- this.focusedStore.entity.setEdit(val);
202
- }
203
- getXStores(y) {
204
- return this.stores[y];
205
- }
206
- getYStores(x) {
207
- const stores = {};
208
- for (let i in this.stores) {
209
- stores[i] = this.stores[i][x];
210
- }
211
- return stores;
212
- }
213
- }
@@ -1,14 +0,0 @@
1
- import reduce from 'lodash/reduce';
2
- import { columnTypes, rowTypes } from '../store/storeTypes';
3
- import ViewportStore from '../store/viewPort/viewport.store';
4
- export default class ViewportProvider {
5
- constructor() {
6
- this.stores = reduce([...rowTypes, ...columnTypes], (sources, k) => {
7
- sources[k] = new ViewportStore();
8
- return sources;
9
- }, {});
10
- }
11
- setViewport(dimensionType, data) {
12
- this.stores[dimensionType].setViewport(data);
13
- }
14
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * All items
3
- * Used as proxy for sorting
4
- * Keep order but do not modify final source
5
- */
6
- export const proxyPlugin = (store) => ({
7
- set(k, newVal) {
8
- if (!isProxy(k)) {
9
- return;
10
- }
11
- /**
12
- * Getting existing collection of items
13
- * Mark indexes as visible
14
- */
15
- const oldItems = store.get('items').reduce((r, v) => {
16
- r[v] = true;
17
- return r;
18
- }, {});
19
- /**
20
- * Check if new values where present in items
21
- * Filter item collection according presense
22
- */
23
- const newItems = newVal.reduce((r, i) => {
24
- if (oldItems[i]) {
25
- r.push(i);
26
- }
27
- return r;
28
- }, []);
29
- store.set('items', newItems);
30
- },
31
- });
32
- function isProxy(k) {
33
- return k === 'proxyItems';
34
- }
@@ -1,127 +0,0 @@
1
- import { createStore } from '@stencil/store';
2
- import findIndex from 'lodash/findIndex';
3
- import range from 'lodash/range';
4
- import { trimmedPlugin } from '../../plugins/trimmed/trimmed.plugin';
5
- import { setStore } from '../../utils/store.utils';
6
- import { proxyPlugin } from './data.proxy';
7
- export default class DataStore {
8
- constructor(type) {
9
- const store = (this.dataStore = createStore({
10
- items: [],
11
- proxyItems: [],
12
- source: [],
13
- groupingDepth: 0,
14
- groups: {},
15
- type,
16
- trimmed: {},
17
- }));
18
- store.use(proxyPlugin(store));
19
- store.use(trimmedPlugin(store));
20
- }
21
- get store() {
22
- return this.dataStore;
23
- }
24
- /**
25
- * full data source update
26
- * @param source - data column/rgRow source
27
- * @param grouping - grouping information if present
28
- */
29
- updateData(source, grouping, silent = false) {
30
- // during full update we do drop trim
31
- if (!silent) {
32
- this.store.set('trimmed', {});
33
- }
34
- // clear items
35
- this.store.set('items', []);
36
- const items = range(0, (source === null || source === void 0 ? void 0 : source.length) || 0);
37
- // set proxy first
38
- setStore(this.store, {
39
- source,
40
- proxyItems: [...items],
41
- });
42
- // update data items
43
- this.store.set('items', items);
44
- // apply grooping if present
45
- if (grouping) {
46
- setStore(this.store, {
47
- groupingDepth: grouping.depth,
48
- groups: grouping.groups,
49
- });
50
- }
51
- }
52
- addTrimmed(some) {
53
- let trimmed = this.store.get('trimmed');
54
- trimmed = Object.assign(Object.assign({}, trimmed), some);
55
- setStore(this.store, { trimmed });
56
- }
57
- // local data update
58
- setData(input) {
59
- const data = Object.assign({}, input);
60
- setStore(this.store, data);
61
- }
62
- refresh() {
63
- const source = this.store.get('source');
64
- this.store.set('source', [...source]);
65
- }
66
- }
67
- /**
68
- * get physical index by virtual
69
- * @param store - store to process
70
- */
71
- export function getPhysical(store, virtualIndex) {
72
- const items = store.get('items');
73
- return items[virtualIndex];
74
- }
75
- /**
76
- * get all visible items
77
- * @param store - store to process
78
- */
79
- export function getVisibleSourceItem(store) {
80
- const source = store.get('source');
81
- return store.get('items').map(v => source[v]);
82
- }
83
- /**
84
- * get mapped item from source
85
- * @param store - store to process
86
- * @param virtualIndex - virtual index to process
87
- */
88
- export function getSourceItem(store, virtualIndex) {
89
- const items = store.get('items');
90
- const source = store.get('source');
91
- return source[items[virtualIndex]];
92
- }
93
- /**
94
- * set item to source
95
- * @param store - store to process
96
- * @param modelByIndex - collection of rows with virtual indexes to setup
97
- */
98
- export function setSourceByVirtualIndex(store, modelByIndex) {
99
- const items = store.get('items');
100
- const source = store.get('source');
101
- for (let virtualIndex in modelByIndex) {
102
- const realIndex = items[virtualIndex];
103
- source[realIndex] = modelByIndex[virtualIndex];
104
- }
105
- store.set('source', [...source]);
106
- }
107
- /**
108
- * set item to source
109
- * @param store - store to process
110
- * @param modelByIndex - collection of rows with physical indexes to setup
111
- */
112
- export function setSourceByPhysicalIndex(store, modelByIndex) {
113
- const source = store.get('source');
114
- for (let index in modelByIndex) {
115
- source[index] = modelByIndex[index];
116
- }
117
- store.set('source', [...source]);
118
- }
119
- export function setItems(store, items) {
120
- store.set('items', items);
121
- }
122
- export function getSourceItemVirtualIndexByProp(store, prop) {
123
- const items = store.get('items');
124
- const source = store.get('source');
125
- const physicalIndex = findIndex(source, { prop });
126
- return items.indexOf(physicalIndex);
127
- }
@@ -1,107 +0,0 @@
1
- import each from 'lodash/each';
2
- import sortedIndex from 'lodash/sortedIndex';
3
- import reduce from 'lodash/reduce';
4
- import { mergeSortedArray } from '../../utils/utils';
5
- /**
6
- * Pre-calculation
7
- * Dimension sizes for each cell
8
- */
9
- export function calculateDimensionData(state, newSizes) {
10
- let positionIndexes = [];
11
- const positionIndexToItem = {};
12
- const indexToItem = {};
13
- // to compare how real width changed
14
- let newTotal = 0;
15
- // combine all sizes
16
- const sizes = Object.assign(Object.assign({}, state.sizes), newSizes);
17
- // prepare order sorted new sizes and calculate changed real size
18
- let newIndexes = [];
19
- each(newSizes, (size, index) => {
20
- // if first introduced custom size
21
- if (!state.sizes[index]) {
22
- newTotal += size - (state.realSize ? state.originItemSize : 0);
23
- newIndexes.splice(sortedIndex(newIndexes, parseInt(index, 10)), 0, parseInt(index, 10));
24
- }
25
- else {
26
- newTotal += size - state.sizes[index];
27
- }
28
- });
29
- // add order to cached order collection for faster linking
30
- const updatedIndexesCache = mergeSortedArray(state.indexes, newIndexes);
31
- // fill new coordinates
32
- reduce(updatedIndexesCache, (previous, itemIndex, i) => {
33
- const newItem = {
34
- itemIndex,
35
- start: 0,
36
- end: 0,
37
- };
38
- if (previous) {
39
- newItem.start = (itemIndex - previous.itemIndex - 1) * state.originItemSize + previous.end;
40
- }
41
- else {
42
- newItem.start = itemIndex * state.originItemSize;
43
- }
44
- newItem.end = newItem.start + sizes[itemIndex];
45
- positionIndexes.push(newItem.start);
46
- indexToItem[itemIndex] = positionIndexToItem[i] = newItem;
47
- return newItem;
48
- }, undefined);
49
- return {
50
- indexes: updatedIndexesCache,
51
- positionIndexes: [...positionIndexes],
52
- positionIndexToItem: Object.assign({}, positionIndexToItem),
53
- indexToItem,
54
- realSize: state.realSize + newTotal,
55
- sizes,
56
- };
57
- }
58
- export function getItemByPosition({ indexes, positionIndexes, originItemSize, positionIndexToItem }, pos) {
59
- const item = {
60
- itemIndex: 0,
61
- start: 0,
62
- end: 0,
63
- };
64
- const currentPlace = indexes.length ? sortedIndex(positionIndexes, pos) : 0;
65
- // not found or first index
66
- if (!currentPlace) {
67
- item.itemIndex = Math.floor(pos / originItemSize);
68
- item.start = item.itemIndex * originItemSize;
69
- item.end = item.start + originItemSize;
70
- return item;
71
- }
72
- const positionItem = positionIndexToItem[currentPlace - 1];
73
- // if item has specified size
74
- if (positionItem.end > pos) {
75
- return positionItem;
76
- }
77
- // special size item was present before
78
- const relativePos = pos - positionItem.end;
79
- const relativeIndex = Math.floor(relativePos / originItemSize);
80
- item.itemIndex = positionItem.itemIndex + 1 + relativeIndex;
81
- item.start = positionItem.end + relativeIndex * originItemSize;
82
- item.end = item.start + originItemSize;
83
- return item;
84
- }
85
- export function getItemByIndex(dimension, index) {
86
- let item = {
87
- itemIndex: index,
88
- start: 0,
89
- end: 0,
90
- };
91
- // if item has specified size
92
- if (dimension.indexToItem[index]) {
93
- return dimension.indexToItem[index];
94
- }
95
- const currentPlace = dimension.indexes.length ? sortedIndex(dimension.indexes, index) : 0;
96
- // not found or first index
97
- if (!currentPlace) {
98
- item.start = item.itemIndex * dimension.originItemSize;
99
- item.end = item.start + dimension.originItemSize;
100
- return item;
101
- }
102
- // special size item was present before
103
- const positionItem = dimension.indexToItem[dimension.indexes[currentPlace - 1]];
104
- item.start = positionItem.end + (index - positionItem.itemIndex - 1) * dimension.originItemSize;
105
- item.end = item.start + dimension.originItemSize;
106
- return item;
107
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * Storing pre-calculated
3
- * Dimension information and sizes
4
- */
5
- import { createStore } from '@stencil/store';
6
- import reduce from 'lodash/reduce';
7
- import { setStore } from '../../utils/store.utils';
8
- import { calculateDimensionData } from './dimension.helpers';
9
- function initialBase() {
10
- return {
11
- indexes: [],
12
- // item index to size
13
- sizes: {},
14
- // order in indexes[] to coordinate
15
- positionIndexToItem: {},
16
- // initial element to coordinate ^
17
- indexToItem: {},
18
- positionIndexes: []
19
- };
20
- }
21
- function initialState() {
22
- return Object.assign(Object.assign({}, initialBase()), {
23
- // size which all items can take
24
- realSize: 0,
25
- // initial item size if it wasn't changed
26
- originItemSize: 0, frameOffset: 0 });
27
- }
28
- export default class DimensionStore {
29
- constructor() {
30
- this.store = createStore(initialState());
31
- }
32
- getCurrentState() {
33
- const state = initialState();
34
- const keys = Object.keys(state);
35
- return reduce(keys, (r, k) => {
36
- const data = this.store.get(k);
37
- r[k] = data;
38
- return r;
39
- }, state);
40
- }
41
- setRealSize(count) {
42
- let realSize = 0;
43
- for (let i = 0; i < count; i++) {
44
- realSize += this.store.get('sizes')[i] || this.store.get('originItemSize');
45
- }
46
- setStore(this.store, { realSize });
47
- }
48
- setStore(data) {
49
- setStore(this.store, data);
50
- }
51
- drop() {
52
- setStore(this.store, initialBase());
53
- }
54
- setDimensionSize(sizes) {
55
- const dimensionData = calculateDimensionData(this.getCurrentState(), sizes);
56
- setStore(this.store, dimensionData);
57
- return dimensionData;
58
- }
59
- }
@@ -1,53 +0,0 @@
1
- import { EMPTY_INDEX } from '../../services/selection.store.connector';
2
- export function isHiddenStore(pos) {
3
- return pos === EMPTY_INDEX;
4
- }
5
- export function nextCell(cell, lastCell) {
6
- const nextItem = {};
7
- let types = ['x', 'y'];
8
- // previous item check
9
- for (let t of types) {
10
- if (cell[t] < 0) {
11
- nextItem[t] = cell[t];
12
- return nextItem;
13
- }
14
- }
15
- // next item check
16
- for (let t of types) {
17
- if (cell[t] >= lastCell[t]) {
18
- nextItem[t] = cell[t] - lastCell[t];
19
- return nextItem;
20
- }
21
- }
22
- return null;
23
- }
24
- export function cropCellToMax(cell, lastCell) {
25
- const newCell = Object.assign({}, cell);
26
- let types = ['x', 'y'];
27
- // previous item check
28
- for (let t of types) {
29
- if (cell[t] < 0) {
30
- newCell[t] = 0;
31
- }
32
- }
33
- // next item check
34
- for (let t of types) {
35
- if (cell[t] >= lastCell[t]) {
36
- newCell[t] = lastCell[t] - 1;
37
- }
38
- }
39
- return newCell;
40
- }
41
- export function getRange(start, end) {
42
- return start && end
43
- ? {
44
- x: Math.min(start.x, end.x),
45
- y: Math.min(start.y, end.y),
46
- x1: Math.max(start.x, end.x),
47
- y1: Math.max(start.y, end.y),
48
- }
49
- : null;
50
- }
51
- export function isRangeSingleCell(a) {
52
- return a.x === a.x1 && a.y === a.y1;
53
- }
@@ -1,68 +0,0 @@
1
- import { createStore } from '@stencil/store';
2
- import { setStore } from '../../utils/store.utils';
3
- import { getRange } from './selection.helpers';
4
- function defaultState() {
5
- return {
6
- range: null,
7
- tempRange: null,
8
- tempRangeType: null,
9
- focus: null,
10
- edit: null,
11
- lastCell: null,
12
- };
13
- }
14
- export class SelectionStore {
15
- constructor() {
16
- this.unsubscribe = [];
17
- this.store = createStore(defaultState());
18
- this.store.on('set', (key, newVal) => {
19
- if (key === 'tempRange' && !newVal) {
20
- this.store.set('tempRangeType', null);
21
- }
22
- });
23
- }
24
- onChange(propName, cb) {
25
- this.unsubscribe.push(this.store.onChange(propName, cb));
26
- }
27
- clearFocus() {
28
- setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });
29
- }
30
- setFocus(focus, end) {
31
- setStore(this.store, {
32
- focus,
33
- range: getRange(focus, end),
34
- edit: null,
35
- tempRange: null,
36
- });
37
- }
38
- setTempArea(range) {
39
- setStore(this.store, { tempRange: range === null || range === void 0 ? void 0 : range.area, tempRangeType: range === null || range === void 0 ? void 0 : range.type, edit: null });
40
- }
41
- clearTemp() {
42
- setStore(this.store, { tempRange: null });
43
- }
44
- /** Can be applied from selection change or from simple keyboard change clicks */
45
- setRangeArea(range) {
46
- setStore(this.store, { range, edit: null, tempRange: null });
47
- }
48
- setRange(start, end) {
49
- this.setRangeArea(getRange(start, end));
50
- }
51
- setLastCell(lastCell) {
52
- setStore(this.store, { lastCell });
53
- }
54
- setEdit(val) {
55
- const focus = this.store.get('focus');
56
- if (focus && typeof val === 'string') {
57
- setStore(this.store, {
58
- edit: { x: focus.x, y: focus.y, val },
59
- });
60
- return;
61
- }
62
- setStore(this.store, { edit: null });
63
- }
64
- dispose() {
65
- this.unsubscribe.forEach(f => f());
66
- this.store.dispose();
67
- }
68
- }