@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,503 @@
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import { G as GRID_INTERNALS } from './consts-ef824e6f.js';
5
+ import { c as createStore, d as setStore } from './data.store-3263fff9.js';
6
+
7
+ const GROUP_DEPTH = `${GRID_INTERNALS}-depth`;
8
+ const PSEUDO_GROUP_ITEM = `${GRID_INTERNALS}-name`;
9
+ const PSEUDO_GROUP_ITEM_ID = `${GRID_INTERNALS}-id`;
10
+ const PSEUDO_GROUP_ITEM_VALUE = `${GRID_INTERNALS}-value`;
11
+ const PSEUDO_GROUP_COLUMN = `${GRID_INTERNALS}-column`;
12
+ const GROUP_EXPANDED = `${GRID_INTERNALS}-expanded`;
13
+ const GROUP_EXPAND_BTN = `group-expand`;
14
+ const GROUP_EXPAND_EVENT = `groupExpandClick`;
15
+ const GROUPING_ROW_TYPE = 'rgRow';
16
+
17
+ /**
18
+ * Do actual grouping
19
+ * @param array - items to group
20
+ * @param f - function responsible for grouping, returns property to group by
21
+ */
22
+ function groupBy(array, f) {
23
+ const groupsOrder = [];
24
+ const itemsByGroup = {};
25
+ array.forEach((item, i) => {
26
+ // get grouping values
27
+ const groupKeys = JSON.stringify(f(item));
28
+ // new group identification
29
+ if (!itemsByGroup[groupKeys]) {
30
+ itemsByGroup[groupKeys] = new Map();
31
+ // create group parents
32
+ groupsOrder.push({
33
+ children: itemsByGroup[groupKeys],
34
+ id: groupKeys,
35
+ });
36
+ }
37
+ // save to group with previous index
38
+ itemsByGroup[groupKeys].set(i, item);
39
+ });
40
+ return groupsOrder;
41
+ }
42
+ /**
43
+ * Gather data for grouping
44
+ * @param array - flat data array
45
+ * @param mapFunc - mapping function for stringify
46
+ * @param expanded - potentially expanded items if present
47
+ */
48
+ function gatherGrouping(array, mapFunc, { prevExpanded, expandedAll }) {
49
+ // build groups
50
+ const groupsOrder = groupBy(array, mapFunc);
51
+ const itemsMirror = []; // grouped source
52
+ const pseudoGroupTest = {}; // check if group header exists
53
+ // item index in source
54
+ let itemIndex = 0;
55
+ // to save max group depth
56
+ let groupingDepth = 0;
57
+ // collapse all groups in the beginning
58
+ const trimmed = {};
59
+ // index mapping
60
+ const oldNewIndexMap = {};
61
+ // go through groups
62
+ groupsOrder.forEach(group => {
63
+ const parseGroup = getParsedGroup(group.id);
64
+ // extra precaution and type safe guard
65
+ if (!parseGroup) {
66
+ return;
67
+ }
68
+ let depth = 0;
69
+ let skipTrim = !!expandedAll;
70
+ let isExpanded = skipTrim;
71
+ const children = [];
72
+ // add group headers
73
+ parseGroup.reduce((prevVal, groupValue) => {
74
+ prevVal.push(groupValue);
75
+ const newVal = prevVal.join(',');
76
+ // if header not added, add new header
77
+ if (!pseudoGroupTest[newVal]) {
78
+ isExpanded = expandedAll || (prevExpanded && prevExpanded[newVal]);
79
+ itemsMirror.push(getPseudoGroup(groupValue, newVal, depth, group.id, isExpanded));
80
+ // if not first level auto collapse
81
+ if (depth && !isExpanded && !skipTrim) {
82
+ // check if parent expanded, expand this layer too
83
+ const parent = prevVal.slice(0, prevVal.length - 1);
84
+ if (!(prevExpanded && parent.length && prevExpanded[parent.join(',')])) {
85
+ trimmed[itemIndex] = true;
86
+ }
87
+ }
88
+ itemIndex++;
89
+ pseudoGroupTest[newVal] = children;
90
+ }
91
+ // calculate depth
92
+ depth++;
93
+ groupingDepth = depth;
94
+ return prevVal;
95
+ }, []);
96
+ // add regular items
97
+ group.children.forEach((item, oldIndex) => {
98
+ // hide items if group colapsed
99
+ if (!isExpanded && !skipTrim) {
100
+ // collapse rgRow
101
+ trimmed[itemIndex] = true;
102
+ }
103
+ // add items to new source
104
+ itemsMirror.push(item);
105
+ oldNewIndexMap[oldIndex] = itemIndex;
106
+ children.push(itemIndex);
107
+ itemIndex++;
108
+ });
109
+ });
110
+ return {
111
+ // updates source mirror
112
+ sourceWithGroups: itemsMirror,
113
+ // largest depth for grouping
114
+ depth: groupingDepth,
115
+ // used for expand/collapse grouping values
116
+ trimmed,
117
+ // used for mapping old values to new
118
+ oldNewIndexMap,
119
+ // used to get child items in group
120
+ childrenByGroup: pseudoGroupTest,
121
+ };
122
+ }
123
+ function getPseudoGroup(groupValue, value, depth, id, isExpanded = false) {
124
+ return {
125
+ [PSEUDO_GROUP_ITEM]: groupValue,
126
+ [GROUP_DEPTH]: depth,
127
+ [PSEUDO_GROUP_ITEM_ID]: id,
128
+ [PSEUDO_GROUP_ITEM_VALUE]: value,
129
+ [GROUP_EXPANDED]: isExpanded,
130
+ };
131
+ }
132
+ function getGroupingName(rgRow) {
133
+ return rgRow && rgRow[PSEUDO_GROUP_ITEM];
134
+ }
135
+ function isGrouping(rgRow) {
136
+ return rgRow && typeof rgRow[PSEUDO_GROUP_ITEM] !== 'undefined';
137
+ }
138
+ function isGroupingColumn(column) {
139
+ return column && typeof column[PSEUDO_GROUP_COLUMN] !== 'undefined';
140
+ }
141
+ function isArray(data) {
142
+ return typeof data.push !== 'undefined';
143
+ }
144
+ function measureEqualDepth(groupA, groupB) {
145
+ const ln = groupA.length;
146
+ let i = 0;
147
+ for (; i < ln; i++) {
148
+ if (groupA[i] !== groupB[i]) {
149
+ return i;
150
+ }
151
+ }
152
+ return i;
153
+ }
154
+ function getParsedGroup(id) {
155
+ const parseGroup = JSON.parse(id);
156
+ // extra precaution and type safe guard
157
+ if (!isArray(parseGroup)) {
158
+ return null;
159
+ }
160
+ return parseGroup;
161
+ }
162
+ // check if items is child of current clicked group
163
+ function isSameGroup(currentGroup, currentModel, nextModel) {
164
+ const nextGroup = getParsedGroup(nextModel[PSEUDO_GROUP_ITEM_ID]);
165
+ if (!nextGroup) {
166
+ return false;
167
+ }
168
+ const depth = measureEqualDepth(currentGroup, nextGroup);
169
+ return currentModel[GROUP_DEPTH] < depth;
170
+ }
171
+
172
+ function isHiddenStore(pos) {
173
+ return pos === EMPTY_INDEX;
174
+ }
175
+ function nextCell(cell, lastCell) {
176
+ const nextItem = {};
177
+ let types = ['x', 'y'];
178
+ // previous item check
179
+ for (let t of types) {
180
+ if (cell[t] < 0) {
181
+ nextItem[t] = cell[t];
182
+ return nextItem;
183
+ }
184
+ }
185
+ // next item check
186
+ for (let t of types) {
187
+ if (cell[t] >= lastCell[t]) {
188
+ nextItem[t] = cell[t] - lastCell[t];
189
+ return nextItem;
190
+ }
191
+ }
192
+ return null;
193
+ }
194
+ function cropCellToMax(cell, lastCell) {
195
+ const newCell = Object.assign({}, cell);
196
+ let types = ['x', 'y'];
197
+ // previous item check
198
+ for (let t of types) {
199
+ if (cell[t] < 0) {
200
+ newCell[t] = 0;
201
+ }
202
+ }
203
+ // next item check
204
+ for (let t of types) {
205
+ if (cell[t] >= lastCell[t]) {
206
+ newCell[t] = lastCell[t] - 1;
207
+ }
208
+ }
209
+ return newCell;
210
+ }
211
+ function getRange(start, end) {
212
+ return start && end
213
+ ? {
214
+ x: Math.min(start.x, end.x),
215
+ y: Math.min(start.y, end.y),
216
+ x1: Math.max(start.x, end.x),
217
+ y1: Math.max(start.y, end.y),
218
+ }
219
+ : null;
220
+ }
221
+ function isRangeSingleCell(a) {
222
+ return a.x === a.x1 && a.y === a.y1;
223
+ }
224
+
225
+ function defaultState() {
226
+ return {
227
+ range: null,
228
+ tempRange: null,
229
+ tempRangeType: null,
230
+ focus: null,
231
+ edit: null,
232
+ lastCell: null,
233
+ };
234
+ }
235
+ class SelectionStore {
236
+ constructor() {
237
+ this.unsubscribe = [];
238
+ this.store = createStore(defaultState());
239
+ this.store.on('set', (key, newVal) => {
240
+ if (key === 'tempRange' && !newVal) {
241
+ this.store.set('tempRangeType', null);
242
+ }
243
+ });
244
+ }
245
+ onChange(propName, cb) {
246
+ this.unsubscribe.push(this.store.onChange(propName, cb));
247
+ }
248
+ clearFocus() {
249
+ setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });
250
+ }
251
+ setFocus(focus, end) {
252
+ setStore(this.store, {
253
+ focus,
254
+ range: getRange(focus, end),
255
+ edit: null,
256
+ tempRange: null,
257
+ });
258
+ }
259
+ setTempArea(range) {
260
+ 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 });
261
+ }
262
+ clearTemp() {
263
+ setStore(this.store, { tempRange: null });
264
+ }
265
+ /** Can be applied from selection change or from simple keyboard change clicks */
266
+ setRangeArea(range) {
267
+ setStore(this.store, { range, edit: null, tempRange: null });
268
+ }
269
+ setRange(start, end) {
270
+ this.setRangeArea(getRange(start, end));
271
+ }
272
+ setLastCell(lastCell) {
273
+ setStore(this.store, { lastCell });
274
+ }
275
+ setEdit(val) {
276
+ const focus = this.store.get('focus');
277
+ if (focus && typeof val === 'string') {
278
+ setStore(this.store, {
279
+ edit: { x: focus.x, y: focus.y, val },
280
+ });
281
+ return;
282
+ }
283
+ setStore(this.store, { edit: null });
284
+ }
285
+ dispose() {
286
+ this.unsubscribe.forEach(f => f());
287
+ this.store.dispose();
288
+ }
289
+ }
290
+
291
+ const EMPTY_INDEX = -1;
292
+ class SelectionStoreConnector {
293
+ constructor() {
294
+ // dirty flag required to cleanup whole store in case visibility of panels changed
295
+ this.dirty = false;
296
+ this.stores = {};
297
+ this.columnStores = {};
298
+ this.rowStores = {};
299
+ this.sections = [];
300
+ }
301
+ get focusedStore() {
302
+ var _a;
303
+ for (let y in this.stores) {
304
+ for (let x in this.stores[y]) {
305
+ const focused = (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.store.get('focus');
306
+ if (focused) {
307
+ return {
308
+ entity: this.stores[y][x],
309
+ cell: focused,
310
+ position: {
311
+ x: parseInt(x, 10),
312
+ y: parseInt(y, 10)
313
+ }
314
+ };
315
+ }
316
+ }
317
+ }
318
+ return null;
319
+ }
320
+ get edit() {
321
+ var _a;
322
+ return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('edit');
323
+ }
324
+ get focused() {
325
+ var _a;
326
+ return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('focus');
327
+ }
328
+ get selectedRange() {
329
+ var _a;
330
+ return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('range');
331
+ }
332
+ registerSection(e) {
333
+ if (!e) {
334
+ this.sections.length = 0;
335
+ // some elements removed, rebuild stores
336
+ this.dirty = true;
337
+ return;
338
+ }
339
+ if (this.sections.indexOf(e) === -1) {
340
+ this.sections.push(e);
341
+ }
342
+ }
343
+ // check if require to cleanup all stores
344
+ beforeUpdate() {
345
+ if (this.dirty) {
346
+ for (let y in this.stores) {
347
+ for (let x in this.stores[y]) {
348
+ this.stores[y][x].dispose();
349
+ }
350
+ }
351
+ this.dirty = false;
352
+ }
353
+ }
354
+ registerColumn(x) {
355
+ // if hidden just create store
356
+ if (isHiddenStore(x)) {
357
+ return new SelectionStore();
358
+ }
359
+ if (this.columnStores[x]) {
360
+ return this.columnStores[x];
361
+ }
362
+ this.columnStores[x] = new SelectionStore();
363
+ return this.columnStores[x];
364
+ }
365
+ registerRow(y) {
366
+ // if hidden just create store
367
+ if (isHiddenStore(y)) {
368
+ return new SelectionStore();
369
+ }
370
+ if (this.rowStores[y]) {
371
+ return this.rowStores[y];
372
+ }
373
+ this.rowStores[y] = new SelectionStore();
374
+ return this.rowStores[y];
375
+ }
376
+ /**
377
+ * Cross store proxy, based on multiple dimensions
378
+ */
379
+ register({ x, y }) {
380
+ var _a, _b;
381
+ // if hidden just create store
382
+ if (isHiddenStore(x) || isHiddenStore(y)) {
383
+ return new SelectionStore();
384
+ }
385
+ if (!this.stores[y]) {
386
+ this.stores[y] = {};
387
+ }
388
+ if (this.stores[y][x]) {
389
+ // Store already registered. Do not register twice
390
+ return this.stores[y][x];
391
+ }
392
+ this.stores[y][x] = new SelectionStore();
393
+ // proxy update
394
+ (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.onChange('range', c => {
395
+ this.columnStores[x].setRangeArea(c);
396
+ this.rowStores[y].setRangeArea(c);
397
+ });
398
+ // clean up on remove
399
+ (_b = this.stores[y][x]) === null || _b === void 0 ? void 0 : _b.store.on('dispose', () => {
400
+ var _a, _b;
401
+ (_a = this.columnStores[x]) === null || _a === void 0 ? void 0 : _a.dispose();
402
+ (_b = this.rowStores[y]) === null || _b === void 0 ? void 0 : _b.dispose();
403
+ delete this.rowStores[y];
404
+ delete this.columnStores[x];
405
+ if (this.stores[y]) {
406
+ delete this.stores[y][x];
407
+ }
408
+ // clear empty rows
409
+ if (!Object.keys(this.stores[y] || {}).length) {
410
+ delete this.stores[y];
411
+ }
412
+ });
413
+ return this.stores[y][x];
414
+ }
415
+ setEditByCell({ x, y }, editCell) {
416
+ const store = this.stores[y][x];
417
+ this.focus(store, { focus: editCell, end: editCell });
418
+ this.setEdit('');
419
+ }
420
+ focus(store, { focus, end }) {
421
+ let currentStorePointer;
422
+ // clear all stores focus leave only active one
423
+ for (let y in this.stores) {
424
+ for (let x in this.stores[y]) {
425
+ const s = this.stores[y][x];
426
+ // clear other stores, only one area can be selected
427
+ if (s !== store) {
428
+ s.clearFocus();
429
+ }
430
+ else {
431
+ currentStorePointer = { x: parseInt(x, 10), y: parseInt(y, 10) };
432
+ }
433
+ }
434
+ }
435
+ if (!currentStorePointer) {
436
+ return;
437
+ }
438
+ // check is focus in next store
439
+ const lastCell = store.store.get('lastCell');
440
+ // item in new store
441
+ const nextItem = nextCell(focus, lastCell);
442
+ let nextStore;
443
+ if (nextItem) {
444
+ for (let i in nextItem) {
445
+ let type = i;
446
+ let stores;
447
+ switch (type) {
448
+ case 'x':
449
+ stores = this.getXStores(currentStorePointer.y);
450
+ break;
451
+ case 'y':
452
+ stores = this.getYStores(currentStorePointer.x);
453
+ break;
454
+ }
455
+ if (nextItem[type] >= 0) {
456
+ nextStore = stores[++currentStorePointer[type]];
457
+ }
458
+ else {
459
+ nextStore = stores[--currentStorePointer[type]];
460
+ const nextLastCell = nextStore === null || nextStore === void 0 ? void 0 : nextStore.store.get('lastCell');
461
+ if (nextLastCell) {
462
+ nextItem[type] = nextLastCell[type] + nextItem[type];
463
+ }
464
+ }
465
+ }
466
+ }
467
+ // if next store present - update
468
+ if (nextStore) {
469
+ let item = Object.assign(Object.assign({}, focus), nextItem);
470
+ this.focus(nextStore, { focus: item, end: item });
471
+ return;
472
+ }
473
+ focus = cropCellToMax(focus, lastCell);
474
+ end = cropCellToMax(focus, lastCell);
475
+ store.setFocus(focus, end);
476
+ }
477
+ clearAll() {
478
+ var _a;
479
+ for (let y in this.stores) {
480
+ for (let x in this.stores[y]) {
481
+ (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.clearFocus();
482
+ }
483
+ }
484
+ }
485
+ setEdit(val) {
486
+ if (!this.focusedStore) {
487
+ return;
488
+ }
489
+ this.focusedStore.entity.setEdit(val);
490
+ }
491
+ getXStores(y) {
492
+ return this.stores[y];
493
+ }
494
+ getYStores(x) {
495
+ const stores = {};
496
+ for (let i in this.stores) {
497
+ stores[i] = this.stores[i][x];
498
+ }
499
+ return stores;
500
+ }
501
+ }
502
+
503
+ export { EMPTY_INDEX as E, GROUP_EXPANDED as G, PSEUDO_GROUP_ITEM_ID as P, SelectionStoreConnector as S, getParsedGroup as a, isSameGroup as b, GROUP_DEPTH as c, GROUPING_ROW_TYPE as d, PSEUDO_GROUP_ITEM_VALUE as e, PSEUDO_GROUP_COLUMN as f, getGroupingName as g, GROUP_EXPAND_EVENT as h, isGrouping as i, gatherGrouping as j, isGroupingColumn as k, getRange as l, isRangeSingleCell as m, PSEUDO_GROUP_ITEM as n, GROUP_EXPAND_BTN as o };
@@ -1,6 +1,10 @@
1
- import { getItemByIndex, getItemByPosition } from '../../store/dimension/dimension.helpers';
1
+ /*!
2
+ * Built by Revolist
3
+ */
4
+ import { a as getItemByPosition, g as getItemByIndex } from './dimension.helpers-a7944fc4.js';
5
+
2
6
  /** Calculate cell based on x, y position */
3
- export function getCurrentCell({ x, y }, { el, rows, cols }) {
7
+ function getCurrentCell({ x, y }, { el, rows, cols }) {
4
8
  const { top, left, height, width } = el.getBoundingClientRect();
5
9
  let cellY = y - top;
6
10
  // limit to element height
@@ -24,7 +28,7 @@ export function getCurrentCell({ x, y }, { el, rows, cols }) {
24
28
  }
25
29
  return { x: rgCol.itemIndex, y: rgRow.itemIndex };
26
30
  }
27
- export function getCoordinate(range, focus, changes, isMulti = false) {
31
+ function getCoordinate(range, focus, changes, isMulti = false) {
28
32
  const updateCoordinate = (c) => {
29
33
  const start = { x: range.x, y: range.y };
30
34
  const end = isMulti ? { x: range.x1, y: range.y1 } : start;
@@ -41,15 +45,15 @@ export function getCoordinate(range, focus, changes, isMulti = false) {
41
45
  return null;
42
46
  }
43
47
  /** check if out of range */
44
- export function isAfterLast({ x, y }, { lastCell }) {
48
+ function isAfterLast({ x, y }, { lastCell }) {
45
49
  return x >= lastCell.x || y >= lastCell.y;
46
50
  }
47
51
  /** check if out of range */
48
- export function isBeforeFirst({ x, y }) {
52
+ function isBeforeFirst({ x, y }) {
49
53
  return x < 0 || y < 0;
50
54
  }
51
55
  /** Compare cells, only 1 coordinate difference is possible */
52
- export function getDirectionCoordinate(initial, last) {
56
+ function getDirectionCoordinate(initial, last) {
53
57
  const c = ['x', 'y'];
54
58
  for (let k of c) {
55
59
  if (initial[k] !== last[k]) {
@@ -58,7 +62,7 @@ export function getDirectionCoordinate(initial, last) {
58
62
  }
59
63
  return null;
60
64
  }
61
- export function getLargestAxis(initial, last) {
65
+ function getLargestAxis(initial, last) {
62
66
  const cell = {};
63
67
  const c = ['x', 'y'];
64
68
  for (let k of c) {
@@ -80,7 +84,7 @@ function styleByCellProps(styles) {
80
84
  height: `${styles.height}px`,
81
85
  };
82
86
  }
83
- export function getCell({ x, y, x1, y1 }, dimensionRow, dimensionCol) {
87
+ function getCell({ x, y, x1, y1 }, dimensionRow, dimensionCol) {
84
88
  const top = getItemByIndex(dimensionRow, y).start;
85
89
  const left = getItemByIndex(dimensionCol, x).start;
86
90
  const bottom = getItemByIndex(dimensionRow, y1).end;
@@ -94,7 +98,9 @@ export function getCell({ x, y, x1, y1 }, dimensionRow, dimensionCol) {
94
98
  height: bottom - top,
95
99
  };
96
100
  }
97
- export function getElStyle(range, dimensionRow, dimensionCol) {
101
+ function getElStyle(range, dimensionRow, dimensionCol) {
98
102
  const styles = getCell(range, dimensionRow, dimensionCol);
99
103
  return styleByCellProps(styles);
100
104
  }
105
+
106
+ export { getCoordinate as a, isBeforeFirst as b, getCell as c, getCurrentCell as d, getDirectionCoordinate as e, getLargestAxis as f, getElStyle as g, isAfterLast as i };