@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,138 +0,0 @@
1
- import { Component, Prop, h, Host } from '@stencil/core';
2
- import { throttle } from 'lodash';
3
- import { TMP_SELECTION_BG_CLASS } from '../../utils/consts';
4
- import { getElStyle } from '../overlay/selection.utils';
5
- export class RevogrFocus {
6
- constructor() {
7
- this.onChange = throttle((e) => this.doChange(e), 300);
8
- }
9
- doChange(e) {
10
- e === null || e === void 0 ? void 0 : e.scrollIntoView({
11
- block: 'nearest',
12
- inline: 'nearest',
13
- });
14
- }
15
- componentDidRender() {
16
- if (this.el) {
17
- this.onChange(this.el);
18
- }
19
- }
20
- render() {
21
- const data = this.selectionStore.get('tempRange');
22
- const type = this.selectionStore.get('tempRangeType');
23
- if (!data) {
24
- return;
25
- }
26
- let directionY = 'bottom';
27
- let derectionX = 'right';
28
- const range = this.getRange();
29
- if (!range) {
30
- return;
31
- }
32
- if (data.y < range.y) {
33
- directionY = 'top';
34
- }
35
- if (data.x < range.x) {
36
- derectionX = 'left';
37
- }
38
- const directionClass = `${derectionX} ${directionY}`;
39
- const style = getElStyle(data, this.dimensionRow.state, this.dimensionCol.state);
40
- return (h(Host, { class: {
41
- [TMP_SELECTION_BG_CLASS]: true,
42
- [type || '']: true,
43
- }, style: style },
44
- h("div", { class: directionClass, ref: (e) => (this.el = e) })));
45
- }
46
- getRange() {
47
- const range = this.selectionStore.get('range');
48
- if (range) {
49
- return range;
50
- }
51
- const focus = this.selectionStore.get('focus');
52
- if (!focus) {
53
- return null;
54
- }
55
- return Object.assign(Object.assign({}, focus), { x1: focus.x, y1: focus.y });
56
- }
57
- static get is() { return "revogr-temp-range"; }
58
- static get originalStyleUrls() { return {
59
- "$": ["revogr-temp-range-style.scss"]
60
- }; }
61
- static get styleUrls() { return {
62
- "$": ["revogr-temp-range-style.css"]
63
- }; }
64
- static get properties() { return {
65
- "selectionStore": {
66
- "type": "unknown",
67
- "mutable": false,
68
- "complexType": {
69
- "original": "Observable<Selection.SelectionStoreState>",
70
- "resolved": "ObservableMap<SelectionStoreState>",
71
- "references": {
72
- "Observable": {
73
- "location": "import",
74
- "path": "../../interfaces"
75
- },
76
- "Selection": {
77
- "location": "import",
78
- "path": "../../interfaces"
79
- }
80
- }
81
- },
82
- "required": false,
83
- "optional": false,
84
- "docs": {
85
- "tags": [],
86
- "text": "Dynamic stores"
87
- }
88
- },
89
- "dimensionRow": {
90
- "type": "unknown",
91
- "mutable": false,
92
- "complexType": {
93
- "original": "Observable<RevoGrid.DimensionSettingsState>",
94
- "resolved": "ObservableMap<DimensionSettingsState>",
95
- "references": {
96
- "Observable": {
97
- "location": "import",
98
- "path": "../../interfaces"
99
- },
100
- "RevoGrid": {
101
- "location": "import",
102
- "path": "../../interfaces"
103
- }
104
- }
105
- },
106
- "required": false,
107
- "optional": false,
108
- "docs": {
109
- "tags": [],
110
- "text": ""
111
- }
112
- },
113
- "dimensionCol": {
114
- "type": "unknown",
115
- "mutable": false,
116
- "complexType": {
117
- "original": "Observable<RevoGrid.DimensionSettingsState>",
118
- "resolved": "ObservableMap<DimensionSettingsState>",
119
- "references": {
120
- "Observable": {
121
- "location": "import",
122
- "path": "../../interfaces"
123
- },
124
- "RevoGrid": {
125
- "location": "import",
126
- "path": "../../interfaces"
127
- }
128
- }
129
- },
130
- "required": false,
131
- "optional": false,
132
- "docs": {
133
- "tags": [],
134
- "text": ""
135
- }
136
- }
137
- }; }
138
- }
@@ -1 +0,0 @@
1
- export * from './components';
@@ -1,230 +0,0 @@
1
- /**
2
- * Plugin module for revo-grid grid system
3
- * Add support for automatic column resize
4
- */
5
- import each from 'lodash/each';
6
- import reduce from 'lodash/reduce';
7
- import BasePlugin from './basePlugin';
8
- import ColumnDataProvider from '../services/column.data.provider';
9
- import { columnTypes } from '../store/storeTypes';
10
- import { getSourceItem } from '../store/dataSource/data.store';
11
- const LETTER_BLOCK_SIZE = 7;
12
- var ColumnAutoSizeMode;
13
- (function (ColumnAutoSizeMode) {
14
- // increases column width on header click according the largest text value
15
- ColumnAutoSizeMode["headerClickAutosize"] = "headerClickAutoSize";
16
- // increases column width on data set and text edit, decreases performance
17
- ColumnAutoSizeMode["autoSizeOnTextOverlap"] = "autoSizeOnTextOverlap";
18
- // increases and decreases column width based on all items sizes, worst for performance
19
- ColumnAutoSizeMode["autoSizeAll"] = "autoSizeAll";
20
- })(ColumnAutoSizeMode || (ColumnAutoSizeMode = {}));
21
- export default class AutoSizeColumn extends BasePlugin {
22
- constructor(revogrid, providers, config) {
23
- super(revogrid);
24
- this.providers = providers;
25
- this.config = config;
26
- this.autoSizeColumns = null;
27
- /** for edge case when no columns defined before data */
28
- this.dataResolve = null;
29
- this.dataReject = null;
30
- this.letterBlockSize = (config === null || config === void 0 ? void 0 : config.letterBlockSize) || LETTER_BLOCK_SIZE;
31
- // create test container to check text width
32
- if (config === null || config === void 0 ? void 0 : config.preciseSize) {
33
- this.precsizeCalculationArea = this.initiatePresizeElement();
34
- revogrid.appendChild(this.precsizeCalculationArea);
35
- }
36
- const aftersourceset = ({ detail: { source } }) => {
37
- this.setSource(source);
38
- };
39
- const afteredit = ({ detail }) => {
40
- this.afteredit(detail);
41
- };
42
- const afterEditAll = ({ detail }) => {
43
- this.afterEditAll(detail);
44
- };
45
- const beforecolumnsset = ({ detail: { columns } }) => {
46
- this.columnSet(columns);
47
- };
48
- const headerDblClick = ({ detail }) => {
49
- const type = ColumnDataProvider.getColumnType(detail);
50
- const size = this.getColumnSize(detail.index, type);
51
- if (size) {
52
- this.providers.dimensionProvider.setDimensionSize(type, {
53
- [detail.index]: size,
54
- });
55
- }
56
- };
57
- this.addEventListener('beforecolumnsset', beforecolumnsset);
58
- switch (config === null || config === void 0 ? void 0 : config.mode) {
59
- case ColumnAutoSizeMode.autoSizeOnTextOverlap:
60
- this.addEventListener('aftersourceset', aftersourceset);
61
- this.addEventListener('afteredit', afteredit);
62
- break;
63
- case ColumnAutoSizeMode.autoSizeAll:
64
- this.addEventListener('aftersourceset', aftersourceset);
65
- this.addEventListener('afteredit', afterEditAll);
66
- break;
67
- default:
68
- this.addEventListener('headerdblClick', headerDblClick);
69
- break;
70
- }
71
- }
72
- async setSource(source) {
73
- let autoSize = this.autoSizeColumns;
74
- if (this.dataReject) {
75
- this.dataReject();
76
- this.clearPromise();
77
- }
78
- /** If data set first and no column provided await until get one */
79
- if (!autoSize) {
80
- const request = new Promise((resolve, reject) => {
81
- this.dataResolve = resolve;
82
- this.dataReject = reject;
83
- });
84
- try {
85
- autoSize = await request;
86
- }
87
- catch (e) {
88
- return;
89
- }
90
- }
91
- // calculate sizes
92
- each(autoSize, (_v, type) => {
93
- const sizes = {};
94
- each(autoSize[type], rgCol => {
95
- // calculate size
96
- rgCol.size = sizes[rgCol.index] = source.reduce((prev, rgRow) => Math.max(prev, this.getLength(rgRow[rgCol.prop])), 0);
97
- });
98
- this.providers.dimensionProvider.setDimensionSize(type, sizes);
99
- });
100
- }
101
- getLength(len) {
102
- var _a;
103
- const padding = 15;
104
- if (!len) {
105
- return 0;
106
- }
107
- try {
108
- const str = len.toString();
109
- /**if exact calculation required proxy with html element, slow operation */
110
- if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.preciseSize) {
111
- this.precsizeCalculationArea.innerText = str;
112
- return this.precsizeCalculationArea.scrollWidth + padding * 2;
113
- }
114
- return str.length * this.letterBlockSize + padding * 2;
115
- }
116
- catch (e) {
117
- return 0;
118
- }
119
- }
120
- afteredit(e) {
121
- let data;
122
- if (this.isRangeEdit(e)) {
123
- data = e.data;
124
- }
125
- else {
126
- data = { 0: { [e.prop]: e.val } };
127
- }
128
- each(this.autoSizeColumns, (columns, type) => {
129
- const sizes = {};
130
- each(columns, rgCol => {
131
- // calculate size
132
- const size = reduce(data, (prev, rgRow) => {
133
- if (typeof rgRow[rgCol.prop] === 'undefined') {
134
- return prev;
135
- }
136
- return Math.max(prev || 0, this.getLength(rgRow[rgCol.prop]));
137
- }, undefined);
138
- if (size && rgCol.size < size) {
139
- rgCol.size = sizes[rgCol.index] = size;
140
- }
141
- });
142
- this.providers.dimensionProvider.setDimensionSize(type, sizes);
143
- });
144
- }
145
- afterEditAll(e) {
146
- const props = {};
147
- if (this.isRangeEdit(e)) {
148
- each(e.data, r => each(r, (_v, p) => (props[p] = true)));
149
- }
150
- else {
151
- props[e.prop] = true;
152
- }
153
- each(this.autoSizeColumns, (columns, type) => {
154
- const sizes = {};
155
- each(columns, rgCol => {
156
- if (props[rgCol.prop]) {
157
- const size = this.getColumnSize(rgCol.index, type);
158
- if (size) {
159
- sizes[rgCol.index] = size;
160
- }
161
- }
162
- });
163
- this.providers.dimensionProvider.setDimensionSize(type, sizes);
164
- });
165
- }
166
- getColumnSize(index, type) {
167
- const rgCol = this.autoSizeColumns[type][index];
168
- if (!rgCol) {
169
- return 0;
170
- }
171
- return reduce(this.providers.dataProvider.stores, (r, s) => {
172
- const perStore = reduce(s.store.get('items'), (prev, _row, i) => {
173
- const item = getSourceItem(s.store, i);
174
- return Math.max(prev || 0, this.getLength(item[rgCol.prop]));
175
- }, 0);
176
- return Math.max(r, perStore);
177
- }, rgCol.size || 0);
178
- }
179
- columnSet(columns) {
180
- var _a;
181
- for (let t of columnTypes) {
182
- const type = t;
183
- const cols = columns[type];
184
- for (let i in cols) {
185
- if (cols[i].autoSize || ((_a = this.config) === null || _a === void 0 ? void 0 : _a.allColumns)) {
186
- if (!this.autoSizeColumns) {
187
- this.autoSizeColumns = {};
188
- }
189
- if (!this.autoSizeColumns[type]) {
190
- this.autoSizeColumns[type] = {};
191
- }
192
- this.autoSizeColumns[type][i] = Object.assign(Object.assign({}, cols[i]), { index: parseInt(i, 10) });
193
- }
194
- }
195
- }
196
- if (this.dataResolve) {
197
- this.dataResolve(this.autoSizeColumns);
198
- this.clearPromise();
199
- }
200
- }
201
- clearPromise() {
202
- this.dataResolve = null;
203
- this.dataReject = null;
204
- }
205
- isRangeEdit(e) {
206
- return !!e.data;
207
- }
208
- initiatePresizeElement() {
209
- const styleForFontTest = {
210
- position: 'absolute',
211
- fontSize: '14px',
212
- height: '0',
213
- width: '0',
214
- whiteSpace: 'nowrap',
215
- top: '0',
216
- overflowX: 'scroll',
217
- };
218
- const el = document.createElement('div');
219
- for (let s in styleForFontTest) {
220
- el.style[s] = styleForFontTest[s];
221
- }
222
- el.classList.add('revo-test-container');
223
- return el;
224
- }
225
- destroy() {
226
- var _a;
227
- super.destroy();
228
- (_a = this.precsizeCalculationArea) === null || _a === void 0 ? void 0 : _a.remove();
229
- }
230
- }
@@ -1,27 +0,0 @@
1
- export default class BasePlugin {
2
- constructor(revogrid) {
3
- this.revogrid = revogrid;
4
- this.subscriptions = {};
5
- }
6
- addEventListener(name, func) {
7
- this.revogrid.addEventListener(name, func);
8
- this.subscriptions[name] = func;
9
- }
10
- removeEventListener(type) {
11
- this.revogrid.removeEventListener(type, this.subscriptions[type]);
12
- delete this.subscriptions[type];
13
- }
14
- emit(eventName, detail) {
15
- const event = new CustomEvent(eventName, { detail: detail, cancelable: true });
16
- this.revogrid.dispatchEvent(event);
17
- return event;
18
- }
19
- clearSubscriptions() {
20
- for (let type in this.subscriptions) {
21
- this.removeEventListener(type);
22
- }
23
- }
24
- destroy() {
25
- this.clearSubscriptions();
26
- }
27
- }
@@ -1,68 +0,0 @@
1
- import { getGroupingName, isGrouping } from '../groupingRow/grouping.service';
2
- const INITIAL = {
3
- mime: 'text/csv',
4
- fileKind: 'csv',
5
- // BOM signature
6
- bom: true,
7
- columnDelimiter: ',',
8
- rowDelimiter: '\r\n',
9
- encoding: '',
10
- };
11
- // The ASCII character code 13 is called a Carriage Return or CR.
12
- const CARRIAGE_RETURN = String.fromCharCode(13);
13
- // Chr(13) followed by a Chr(10) that compose a proper CRLF.
14
- const LINE_FEED = String.fromCharCode(10);
15
- const DOUBLE_QT = String.fromCharCode(34);
16
- const NO_BREAK_SPACE = String.fromCharCode(0xfeff);
17
- const escapeRegex = new RegExp('"', 'g');
18
- export default class ExportCsv {
19
- constructor(options = {}) {
20
- this.options = Object.assign(Object.assign({}, INITIAL), options);
21
- }
22
- doExport({ data, headers, props }) {
23
- let result = this.options.bom ? NO_BREAK_SPACE : '';
24
- // any header
25
- if ((headers === null || headers === void 0 ? void 0 : headers.length) > 0) {
26
- headers.forEach(header => {
27
- // ignore empty
28
- if (!header.length) {
29
- return;
30
- }
31
- result += this.prepareHeader(header, this.options.columnDelimiter);
32
- result += this.options.rowDelimiter;
33
- });
34
- }
35
- data.forEach((rgRow, index) => {
36
- if (index > 0) {
37
- result += this.options.rowDelimiter;
38
- }
39
- // support grouping
40
- if (isGrouping(rgRow)) {
41
- result += this.parseCell(getGroupingName(rgRow), this.options.columnDelimiter);
42
- return;
43
- }
44
- result += props.map(p => this.parseCell(rgRow[p], this.options.columnDelimiter)).join(this.options.columnDelimiter);
45
- });
46
- return result;
47
- }
48
- prepareHeader(columnHeaders, columnDelimiter) {
49
- let result = '';
50
- const newColumnHeaders = columnHeaders.map(v => this.parseCell(v, columnDelimiter, true));
51
- result += newColumnHeaders.join(columnDelimiter);
52
- return result;
53
- }
54
- parseCell(value, columnDelimiter, force = false) {
55
- let escape = value;
56
- if (typeof value !== 'string') {
57
- escape = JSON.stringify(value);
58
- }
59
- const toEscape = [CARRIAGE_RETURN, DOUBLE_QT, LINE_FEED, columnDelimiter];
60
- if (typeof escape === 'undefined') {
61
- return '';
62
- }
63
- if (escape !== '' && (force || toEscape.some(i => escape.indexOf(i) >= 0))) {
64
- return `"${escape.replace(escapeRegex, '""')}"`;
65
- }
66
- return escape;
67
- }
68
- }
@@ -1,165 +0,0 @@
1
- import fill from 'lodash/fill';
2
- import { columnTypes, rowTypes } from '../../store/storeTypes';
3
- import { timeout } from '../../utils/utils';
4
- import BasePlugin from '../basePlugin';
5
- import ExportCsv from './csv';
6
- var ExportTypes;
7
- (function (ExportTypes) {
8
- ExportTypes["csv"] = "csv";
9
- })(ExportTypes || (ExportTypes = {}));
10
- export default class ExportFilePlugin extends BasePlugin {
11
- /** Exports string */
12
- async exportString(options = {}, t = ExportTypes.csv) {
13
- const data = await this.beforeexport();
14
- if (!data) {
15
- return null;
16
- }
17
- return this.formatter(t, options).doExport(data);
18
- }
19
- /** Exports Blob */
20
- async exportBlob(options = {}, t = ExportTypes.csv) {
21
- return await this.getBlob(this.formatter(t, options));
22
- }
23
- /** Export file */
24
- async exportFile(options = {}, t = ExportTypes.csv) {
25
- const formatter = this.formatter(t, options);
26
- const blob = await this.getBlob(formatter);
27
- // url
28
- const URL = window.URL || window.webkitURL;
29
- const a = document.createElement('a');
30
- const { filename, fileKind } = formatter.options;
31
- const name = `${filename}.${fileKind}`;
32
- const url = URL.createObjectURL(blob);
33
- a.style.display = 'none';
34
- a.setAttribute('href', url);
35
- a.setAttribute('download', name);
36
- this.revogrid.appendChild(a);
37
- a.dispatchEvent(new MouseEvent('click'));
38
- this.revogrid.removeChild(a);
39
- // delay for revoke, correct for some browsers
40
- await timeout(120);
41
- URL.revokeObjectURL(url);
42
- }
43
- /** Blob object */
44
- async getBlob(formatter) {
45
- const type = `${formatter.options.mime};charset=${formatter.options.encoding}`;
46
- if (typeof Blob !== 'undefined') {
47
- const data = await this.beforeexport();
48
- if (!data) {
49
- return null;
50
- }
51
- return new Blob([formatter.doExport(data)], { type });
52
- }
53
- return null;
54
- }
55
- // before event
56
- async beforeexport() {
57
- let data = await this.getData();
58
- const event = this.emit('beforeexport', { data });
59
- if (event.defaultPrevented) {
60
- return null;
61
- }
62
- return event.detail.data;
63
- }
64
- async getData() {
65
- const data = await this.getSource();
66
- const colSource = [];
67
- const colPromises = [];
68
- columnTypes.forEach((t, i) => {
69
- colPromises.push(this.getColPerSource(t).then(s => (colSource[i] = s)));
70
- });
71
- await Promise.all(colPromises);
72
- const columns = {
73
- headers: [],
74
- props: [],
75
- };
76
- for (let source of colSource) {
77
- source.headers.forEach((h, i) => {
78
- if (!columns.headers[i]) {
79
- columns.headers[i] = [];
80
- }
81
- columns.headers[i].push(...h);
82
- });
83
- columns.props.push(...source.props);
84
- }
85
- return Object.assign({ data }, columns);
86
- }
87
- async getColPerSource(t) {
88
- const store = await this.revogrid.getColumnStore(t);
89
- const source = store.get('source');
90
- const virtualIndexes = store.get('items');
91
- const depth = store.get('groupingDepth');
92
- const groups = store.get('groups');
93
- const colNames = [];
94
- const colProps = [];
95
- const visibleItems = virtualIndexes.reduce((r, v, virtualIndex) => {
96
- const prop = source[v].prop;
97
- colNames.push(source[v].name || '');
98
- colProps.push(prop);
99
- r[prop] = virtualIndex;
100
- return r;
101
- }, {});
102
- const rows = this.getGroupHeaders(depth, groups, virtualIndexes, visibleItems);
103
- rows.push(colNames);
104
- return {
105
- headers: rows,
106
- props: colProps,
107
- };
108
- }
109
- getGroupHeaders(depth, groups, items, visibleItems) {
110
- const rows = [];
111
- const template = fill(new Array(items.length), '');
112
- for (let d = 0; d < depth; d++) {
113
- const rgRow = [...template];
114
- rows.push(rgRow);
115
- if (!groups[d]) {
116
- continue;
117
- }
118
- const levelGroups = groups[d];
119
- // add names of groups
120
- levelGroups.forEach((group) => {
121
- const minIndex = this.findGroupStartIndex(group.ids, visibleItems);
122
- if (typeof minIndex === 'number') {
123
- rgRow[minIndex] = group.name;
124
- }
125
- });
126
- }
127
- return rows;
128
- }
129
- findGroupStartIndex(ids, visibleItems) {
130
- let min;
131
- ids.forEach(id => {
132
- const current = visibleItems[id];
133
- if (typeof current === 'number') {
134
- if (typeof min !== 'number' || min > current) {
135
- min = current;
136
- }
137
- }
138
- });
139
- return min;
140
- }
141
- async getSource() {
142
- const data = [];
143
- const promisesData = [];
144
- rowTypes.forEach(t => {
145
- const dataPart = [];
146
- data.push(dataPart);
147
- const promise = this.revogrid.getVisibleSource(t).then((d) => dataPart.push(...d));
148
- promisesData.push(promise);
149
- });
150
- await Promise.all(promisesData);
151
- return data.reduce((r, v) => {
152
- r.push(...v);
153
- return r;
154
- }, []);
155
- }
156
- // get correct class for future multiple types support
157
- formatter(type, options = {}) {
158
- switch (type) {
159
- case ExportTypes.csv:
160
- return new ExportCsv(options);
161
- default:
162
- throw new Error('Unknown format');
163
- }
164
- }
165
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- const eq = (value, extra) => {
2
- if (typeof value === 'undefined' || (value === null && !extra)) {
3
- return true;
4
- }
5
- if (typeof value !== 'string') {
6
- value = JSON.stringify(value);
7
- }
8
- const filterVal = extra.toString().toLocaleLowerCase();
9
- if (filterVal.length === 0) {
10
- return true;
11
- }
12
- return value.toLocaleLowerCase() === filterVal;
13
- };
14
- export const notEq = (value, extra) => !eq(value, extra);
15
- notEq.extra = 'input';
16
- eq.extra = 'input';
17
- export default eq;
@@ -1,10 +0,0 @@
1
- const gtThan = function (value, extra) {
2
- let conditionValue;
3
- if (typeof value === 'number') {
4
- conditionValue = parseFloat(extra === null || extra === void 0 ? void 0 : extra.toString());
5
- return value > conditionValue;
6
- }
7
- return false;
8
- };
9
- gtThan.extra = 'input';
10
- export default gtThan;
@@ -1,7 +0,0 @@
1
- import eq from '../equal';
2
- import gt from './greaterThan';
3
- const gtThanEq = function (value, extra) {
4
- return eq(value, extra) || gt(value, extra);
5
- };
6
- gtThanEq.extra = 'input';
7
- export default gtThanEq;
@@ -1,12 +0,0 @@
1
- const lt = function (value, extra) {
2
- let conditionValue;
3
- if (typeof value === 'number') {
4
- conditionValue = parseFloat(extra === null || extra === void 0 ? void 0 : extra.toString());
5
- return value < conditionValue;
6
- }
7
- else {
8
- return false;
9
- }
10
- };
11
- lt.extra = 'input';
12
- export default lt;
@@ -1,7 +0,0 @@
1
- import eq from '../equal';
2
- import lt from './lessThan';
3
- const lsEq = function (value, extra) {
4
- return eq(value, extra) || lt(value, extra);
5
- };
6
- lsEq.extra = 'input';
7
- export default lsEq;