@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
@@ -1,3 +0,0 @@
1
- const set = (value) => !(value === '' || value === null || value === void 0);
2
- export const notSet = (value) => !set(value);
3
- export default set;
@@ -1,17 +0,0 @@
1
- const beginsWith = (value, extra) => {
2
- if (!value) {
3
- return false;
4
- }
5
- if (!extra) {
6
- return true;
7
- }
8
- if (typeof value !== 'string') {
9
- value = JSON.stringify(value);
10
- }
11
- if (typeof extra !== 'string') {
12
- extra = JSON.stringify(extra);
13
- }
14
- return value.toLocaleLowerCase().indexOf(extra.toLocaleLowerCase()) === 0;
15
- };
16
- beginsWith.extra = 'input';
17
- export default beginsWith;
@@ -1,18 +0,0 @@
1
- const contains = (value, extra) => {
2
- if (!value) {
3
- return false;
4
- }
5
- if (extra) {
6
- if (typeof value !== 'string') {
7
- value = JSON.stringify(value);
8
- }
9
- return value.toLocaleLowerCase().indexOf(extra.toString().toLowerCase()) > -1;
10
- }
11
- return true;
12
- };
13
- export const notContains = (value, extra) => {
14
- return !contains(value, extra);
15
- };
16
- notContains.extra = 'input';
17
- contains.extra = 'input';
18
- export default contains;
@@ -1,256 +0,0 @@
1
- import { h } from '@stencil/core';
2
- import BasePlugin from '../basePlugin';
3
- import { FILTER_PROP, isFilterBtn } from './filter.button';
4
- import { filterEntities, filterNames, filterTypes } from './filter.service';
5
- export const FILTER_TRIMMED_TYPE = 'filter';
6
- export default class FilterPlugin extends BasePlugin {
7
- constructor(revogrid, uiid, config) {
8
- var _a;
9
- super(revogrid);
10
- this.revogrid = revogrid;
11
- this.filterCollection = {};
12
- this.multiFilterItems = {};
13
- this.possibleFilters = Object.assign({}, filterTypes);
14
- this.possibleFilterNames = Object.assign({}, filterNames);
15
- this.possibleFilterEntities = Object.assign({}, filterEntities);
16
- if (config) {
17
- this.initConfig(config);
18
- }
19
- const headerclick = (e) => this.headerclick(e);
20
- const aftersourceset = async () => {
21
- const filterCollectionProps = Object.keys(this.filterCollection);
22
- if (filterCollectionProps.length > 0) {
23
- // handle old way of filtering by reworking FilterCollection to new MultiFilterItem
24
- filterCollectionProps.forEach((prop, index) => {
25
- if (!this.multiFilterItems[prop]) {
26
- this.multiFilterItems[prop] = [
27
- {
28
- id: index,
29
- type: this.filterCollection[prop].type,
30
- value: this.filterCollection[prop].value,
31
- relation: 'and',
32
- },
33
- ];
34
- }
35
- });
36
- }
37
- await this.runFiltering();
38
- };
39
- this.addEventListener('headerclick', headerclick);
40
- this.addEventListener('aftersourceset', aftersourceset);
41
- this.revogrid.registerVNode([
42
- h("revogr-filter-panel", { uuid: `filter-${uiid}`, filterItems: this.multiFilterItems, filterNames: this.possibleFilterNames, filterEntities: this.possibleFilterEntities, filterCaptions: (_a = config === null || config === void 0 ? void 0 : config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), disableDynamicFiltering: config === null || config === void 0 ? void 0 : config.disableDynamicFiltering, ref: e => (this.pop = e) }),
43
- ]);
44
- }
45
- initConfig(config) {
46
- if (config.collection) {
47
- this.filterCollection = Object.assign({}, config.collection);
48
- }
49
- if (config.multiFilterItems) {
50
- this.multiFilterItems = Object.assign({}, config.multiFilterItems);
51
- }
52
- if (config.customFilters) {
53
- for (let cType in config.customFilters) {
54
- const cFilter = config.customFilters[cType];
55
- if (!this.possibleFilters[cFilter.columnFilterType]) {
56
- this.possibleFilters[cFilter.columnFilterType] = [];
57
- }
58
- this.possibleFilters[cFilter.columnFilterType].push(cType);
59
- this.possibleFilterEntities[cType] = cFilter.func;
60
- this.possibleFilterNames[cType] = cFilter.name;
61
- }
62
- }
63
- /**
64
- * which filters has to be included/excluded
65
- * convinient way to exclude system filters
66
- */
67
- if (config.include) {
68
- const filters = {};
69
- for (let t in this.possibleFilters) {
70
- // validate filters, if appropriate function present
71
- const newTypes = this.possibleFilters[t].filter(f => config.include.indexOf(f) > -1);
72
- if (newTypes.length) {
73
- filters[t] = newTypes;
74
- }
75
- }
76
- // if any valid filters provided show them
77
- if (Object.keys(filters).length > 0) {
78
- this.possibleFilters = filters;
79
- }
80
- }
81
- if (config.localization) {
82
- if (config.localization.filterNames) {
83
- Object.entries(config.localization.filterNames).forEach(([k, v]) => {
84
- if (this.possibleFilterNames[k] != void 0) {
85
- this.possibleFilterNames[k] = v;
86
- }
87
- });
88
- }
89
- }
90
- }
91
- async headerclick(e) {
92
- var _a;
93
- const el = (_a = e.detail.originalEvent) === null || _a === void 0 ? void 0 : _a.target;
94
- if (!isFilterBtn(el)) {
95
- return;
96
- }
97
- e.preventDefault();
98
- // close if same
99
- const changes = await this.pop.getChanges();
100
- if (changes && (changes === null || changes === void 0 ? void 0 : changes.prop) === e.detail.prop) {
101
- this.pop.show();
102
- return;
103
- }
104
- // filter button clicked, open filter dialog
105
- const gridPos = this.revogrid.getBoundingClientRect();
106
- const buttonPos = el.getBoundingClientRect();
107
- const prop = e.detail.prop;
108
- this.pop.filterTypes = this.getColumnFilter(e.detail.filter);
109
- this.pop.show(Object.assign(Object.assign({}, this.filterCollection[prop]), { x: buttonPos.x - gridPos.x, y: buttonPos.y - gridPos.y + buttonPos.height, prop }));
110
- }
111
- getColumnFilter(type) {
112
- let filterType = 'string';
113
- if (!type) {
114
- return { [filterType]: this.possibleFilters[filterType] };
115
- }
116
- // if custom column filter
117
- if (this.isValidType(type)) {
118
- filterType = type;
119
- // if multiple filters applied
120
- }
121
- else if (typeof type === 'object' && type.length) {
122
- return type.reduce((r, multiType) => {
123
- if (this.isValidType(multiType)) {
124
- r[multiType] = this.possibleFilters[multiType];
125
- }
126
- return r;
127
- }, {});
128
- }
129
- return { [filterType]: this.possibleFilters[filterType] };
130
- }
131
- isValidType(type) {
132
- return !!(typeof type === 'string' && this.possibleFilters[type]);
133
- }
134
- // called on internal component change
135
- async onFilterChange(filterItems) {
136
- this.multiFilterItems = filterItems;
137
- this.runFiltering();
138
- }
139
- /**
140
- * Triggers grid filtering
141
- */
142
- async doFiltering(collection, items, columns, filterItems) {
143
- const columnsToUpdate = [];
144
- columns.forEach(rgCol => {
145
- const column = Object.assign({}, rgCol);
146
- const hasFilter = filterItems[column.prop];
147
- if (column[FILTER_PROP] && !hasFilter) {
148
- delete column[FILTER_PROP];
149
- columnsToUpdate.push(column);
150
- }
151
- if (!column[FILTER_PROP] && hasFilter) {
152
- columnsToUpdate.push(column);
153
- column[FILTER_PROP] = true;
154
- }
155
- });
156
- const itemsToFilter = this.getRowFilter(items, filterItems);
157
- // check is filter event prevented
158
- const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', { collection, itemsToFilter, source: items, filterItems });
159
- if (defaultPrevented) {
160
- return;
161
- }
162
- // check is trimmed event prevented
163
- const isAddedEvent = await this.revogrid.addTrimmed(detail.itemsToFilter, FILTER_TRIMMED_TYPE);
164
- if (isAddedEvent.defaultPrevented) {
165
- return;
166
- }
167
- // applies the hasFilter to the columns to show filter icon
168
- await this.revogrid.updateColumns(columnsToUpdate);
169
- this.emit('afterFilterApply');
170
- }
171
- async clearFiltering() {
172
- this.multiFilterItems = {};
173
- await this.runFiltering();
174
- }
175
- async runFiltering() {
176
- const collection = {};
177
- // handle old filterCollection to return the first filter only (if any) from multiFilterItems
178
- const filterProps = Object.keys(this.multiFilterItems);
179
- for (const prop of filterProps) {
180
- // check if we have any filter for a column
181
- if (this.multiFilterItems[prop].length > 0) {
182
- const firstFilterItem = this.multiFilterItems[prop][0];
183
- collection[prop] = {
184
- filter: filterEntities[firstFilterItem.type],
185
- type: firstFilterItem.type,
186
- value: firstFilterItem.value,
187
- };
188
- }
189
- }
190
- this.filterCollection = collection;
191
- const { source, columns } = await this.getData();
192
- const { defaultPrevented, detail } = this.emit('beforefilterapply', { collection: this.filterCollection, source, columns, filterItems: this.multiFilterItems });
193
- if (defaultPrevented) {
194
- return;
195
- }
196
- this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
197
- }
198
- async getData() {
199
- const source = await this.revogrid.getSource();
200
- const columns = await this.revogrid.getColumns();
201
- return {
202
- source,
203
- columns,
204
- };
205
- }
206
- getRowFilter(rows, filterItems) {
207
- const propKeys = Object.keys(filterItems);
208
- const trimmed = {};
209
- let propFilterSatisfiedCount = 0;
210
- let lastFilterResults = [];
211
- // each rows
212
- rows.forEach((model, rowIndex) => {
213
- // working on all props
214
- for (const prop of propKeys) {
215
- const propFilters = filterItems[prop];
216
- propFilterSatisfiedCount = 0;
217
- lastFilterResults = [];
218
- // testing each filter for a prop
219
- for (const [filterIndex, filterData] of propFilters.entries()) {
220
- // the filter LogicFunction based on the type
221
- const filter = filterEntities[filterData.type];
222
- // THE MAGIC OF FILTERING IS HERE
223
- if (filterData.relation === 'or') {
224
- lastFilterResults = [];
225
- if (filter(model[prop], filterData.value)) {
226
- continue;
227
- }
228
- propFilterSatisfiedCount++;
229
- }
230
- else {
231
- // 'and' relation will need to know the next filter
232
- // so we save this current filter to include it in the next filter
233
- lastFilterResults.push(!filter(model[prop], filterData.value));
234
- // check first if we have a filter on the next index to pair it with this current filter
235
- const nextFilterData = propFilters[filterIndex + 1];
236
- // stop the sequence if there is no next filter or if the next filter is not an 'and' relation
237
- if (!nextFilterData || nextFilterData.relation !== 'and') {
238
- // let's just continue since for sure propFilterSatisfiedCount cannot be satisfied
239
- if (lastFilterResults.indexOf(true) === -1) {
240
- lastFilterResults = [];
241
- continue;
242
- }
243
- // we need to add all of the lastFilterResults since we need to satisfy all
244
- propFilterSatisfiedCount += lastFilterResults.length;
245
- lastFilterResults = [];
246
- }
247
- }
248
- } // end of propFilters forEach
249
- // add to the list of removed/trimmed rows of filter condition is satisfied
250
- if (propFilterSatisfiedCount === propFilters.length)
251
- trimmed[rowIndex] = true;
252
- } // end of for-of propKeys
253
- });
254
- return trimmed;
255
- }
256
- }