@refinitiv-ui/efx-grid 6.0.3 → 6.0.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 (178) hide show
  1. package/lib/column-dragging/es6/ColumnDragging.d.ts +49 -0
  2. package/lib/column-dragging/es6/ColumnDragging.js +764 -0
  3. package/lib/column-dragging/es6/index.d.ts +1 -0
  4. package/lib/column-dragging/es6/index.js +1 -0
  5. package/lib/core/dist/core.css +1 -1
  6. package/lib/core/dist/core.js +389 -1070
  7. package/lib/core/dist/core.min.js +1 -1
  8. package/lib/core/es6/data/ColumnStats.d.ts +2 -2
  9. package/lib/core/es6/data/DataCache.d.ts +4 -4
  10. package/lib/core/es6/data/DataTable.d.ts +5 -5
  11. package/lib/core/es6/data/DataTable.js +1 -1
  12. package/lib/core/es6/data/DataView.d.ts +12 -12
  13. package/lib/core/es6/data/SegmentCollection.d.ts +3 -3
  14. package/lib/core/es6/data/WrappedView.d.ts +13 -13
  15. package/lib/core/es6/grid/Core.d.ts +29 -27
  16. package/lib/core/es6/grid/Core.js +26 -4
  17. package/lib/core/es6/grid/ILayoutGrid.d.ts +15 -15
  18. package/lib/core/es6/grid/LayoutGrid.js +54 -26
  19. package/lib/core/es6/grid/VirtualizedLayoutGrid.js +66 -0
  20. package/lib/core/es6/grid/components/Cell.d.ts +4 -4
  21. package/lib/core/es6/grid/components/CellFloatingPanel.d.ts +1 -1
  22. package/lib/core/es6/grid/components/CellSpans.d.ts +8 -8
  23. package/lib/core/es6/grid/components/Column.d.ts +1 -1
  24. package/lib/core/es6/grid/components/ElementWrapper.d.ts +6 -6
  25. package/lib/core/es6/grid/components/Scrollbar.d.ts +1 -1
  26. package/lib/core/es6/grid/components/StretchedCells.js +2 -2
  27. package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +14 -6
  28. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +147 -81
  29. package/lib/core/es6/grid/util/Conflator.d.ts +2 -2
  30. package/lib/core/es6/grid/util/ElementFrameWork.d.ts +3 -3
  31. package/lib/core/es6/grid/util/HttpRequest.d.ts +2 -2
  32. package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +1 -1
  33. package/lib/core/es6/grid/util/RangeBar.d.ts +1 -1
  34. package/lib/core/es6/grid/util/SectionSettings.d.ts +5 -5
  35. package/lib/core/es6/grid/util/SectionSettings.js +5 -0
  36. package/lib/core/es6/grid/util/SelectionList.d.ts +2 -2
  37. package/lib/core/es6/grid/util/TrackLayout.d.ts +7 -3
  38. package/lib/core/es6/grid/util/TrackLayout.js +27 -0
  39. package/lib/core/es6/grid/util/util.d.ts +2 -2
  40. package/lib/core/es6/index.d.ts +1 -5
  41. package/lib/core/es6/index.js +1 -7
  42. package/lib/core/es6/tr-grid-theme.js +1 -1
  43. package/lib/filter-dialog/lib/filter-dialog.d.ts +1 -0
  44. package/lib/filter-dialog/lib/filter-dialog.js +73 -26
  45. package/lib/filter-dialog/themes/base-checkbox.less +8 -1
  46. package/lib/filter-dialog/themes/base.less +69 -1
  47. package/lib/filter-dialog/themes/elemental/dark/checkbox-list.js +1 -1
  48. package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +2 -2
  49. package/lib/filter-dialog/themes/elemental/dark/filter-dialog.js +1 -1
  50. package/lib/filter-dialog/themes/elemental/light/checkbox-list.js +1 -1
  51. package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +2 -2
  52. package/lib/filter-dialog/themes/elemental/light/filter-dialog.js +1 -1
  53. package/lib/filter-dialog/themes/halo/dark/checkbox-list.js +1 -1
  54. package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +2 -2
  55. package/lib/filter-dialog/themes/halo/dark/filter-dialog.js +1 -1
  56. package/lib/filter-dialog/themes/halo/light/checkbox-list.js +1 -1
  57. package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +2 -2
  58. package/lib/filter-dialog/themes/halo/light/filter-dialog.js +1 -1
  59. package/lib/filter-dialog/themes/solar/charcoal/checkbox-list.js +1 -1
  60. package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +2 -2
  61. package/lib/filter-dialog/themes/solar/charcoal/filter-dialog.js +1 -1
  62. package/lib/filter-dialog/themes/solar/pearl/checkbox-list.js +1 -1
  63. package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +2 -2
  64. package/lib/filter-dialog/themes/solar/pearl/filter-dialog.js +1 -1
  65. package/lib/grid/lib/efx-grid.d.ts +8 -5
  66. package/lib/grid/lib/efx-grid.js +10 -4
  67. package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
  68. package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
  69. package/lib/grid/themes/halo/efx-grid.less +33 -39
  70. package/lib/grid/themes/halo/light/efx-grid.js +1 -1
  71. package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
  72. package/lib/index.d.ts +2 -0
  73. package/lib/index.js +2 -0
  74. package/lib/row-segmenting/es6/RowSegmenting.d.ts +7 -2
  75. package/lib/row-segmenting/es6/RowSegmenting.js +94 -9
  76. package/lib/rt-grid/dist/rt-grid.js +567 -1171
  77. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  78. package/lib/rt-grid/es6/ColumnDefinition.d.ts +5 -3
  79. package/lib/rt-grid/es6/ColumnDefinition.js +17 -108
  80. package/lib/rt-grid/es6/DataConnector.d.ts +3 -3
  81. package/lib/rt-grid/es6/Grid.d.ts +17 -9
  82. package/lib/rt-grid/es6/Grid.js +201 -101
  83. package/lib/rt-grid/es6/RowDefSorter.d.ts +19 -0
  84. package/lib/rt-grid/es6/RowDefSorter.js +137 -0
  85. package/lib/rt-grid/es6/RowDefinition.d.ts +9 -7
  86. package/lib/rt-grid/es6/RowDefinition.js +6 -0
  87. package/lib/rt-grid/es6/SnapshotFiller.d.ts +3 -1
  88. package/lib/rt-grid/es6/SnapshotFiller.js +23 -0
  89. package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +2 -2
  90. package/lib/tr-grid-checkbox/es6/Checkbox.js +38 -20
  91. package/lib/tr-grid-column-selection/es6/ColumnSelection.js +46 -9
  92. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +8 -4
  93. package/lib/tr-grid-column-stack/es6/ColumnStack.js +240 -125
  94. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.d.ts +1 -1
  95. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +18 -12
  96. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +7 -4
  97. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +93 -2
  98. package/lib/tr-grid-printer/es6/CellWriter.d.ts +3 -3
  99. package/lib/tr-grid-printer/es6/GridPrinter.d.ts +1 -1
  100. package/lib/tr-grid-printer/es6/GridPrinter.js +26 -13
  101. package/lib/tr-grid-printer/es6/PrintTrait.d.ts +2 -2
  102. package/lib/tr-grid-printer/es6/SectionWriter.d.ts +3 -3
  103. package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +2 -1
  104. package/lib/tr-grid-row-dragging/es6/RowDragging.js +29 -143
  105. package/lib/tr-grid-row-grouping/es6/RowGrouping.d.ts +7 -2
  106. package/lib/tr-grid-row-grouping/es6/RowGrouping.js +97 -7
  107. package/lib/tr-grid-row-selection/es6/RowSelection.js +10 -0
  108. package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +1 -1
  109. package/lib/tr-grid-textformatting/es6/TextFormatting.js +12 -0
  110. package/lib/tr-grid-util/es6/DragUI.d.ts +16 -0
  111. package/lib/tr-grid-util/es6/DragUI.js +214 -0
  112. package/lib/tr-grid-util/es6/ElementObserver.d.ts +2 -0
  113. package/lib/tr-grid-util/es6/ElementObserver.js +28 -1
  114. package/lib/tr-grid-util/es6/ElfUtil.js +1 -1
  115. package/lib/tr-grid-util/es6/FieldFormatter.js +7 -5
  116. package/lib/tr-grid-util/es6/GridPlugin.js +8 -4
  117. package/lib/tr-grid-util/es6/NumberFormatter.d.ts +2 -0
  118. package/lib/tr-grid-util/es6/NumberFormatter.js +64 -19
  119. package/lib/tr-grid-util/es6/RowPainter.js +41 -11
  120. package/lib/tr-grid-util/es6/formula/Formula.js +9 -1
  121. package/lib/types/es6/Checkbox.d.ts +2 -2
  122. package/lib/types/es6/ColumnStack.d.ts +8 -4
  123. package/lib/types/es6/CompositeGrid/ColumnSelectionPlugin.d.ts +3 -2
  124. package/lib/types/es6/CompositeGrid/ColumnWidthAdjustingPlugin.d.ts +2 -1
  125. package/lib/types/es6/CompositeGrid/CompositeGrid.d.ts +20 -18
  126. package/lib/types/es6/CompositeGrid/DragAndDropTitlePlugin.d.ts +2 -1
  127. package/lib/types/es6/CompositeGrid/DraggableContentPlugin.d.ts +3 -2
  128. package/lib/types/es6/CompositeGrid/Plugin.d.ts +28 -0
  129. package/lib/types/es6/CompositeGrid/ResizableTitlePlugin.d.ts +2 -1
  130. package/lib/types/es6/CompositeGrid/RowSelectionPlugin.d.ts +5 -4
  131. package/lib/types/es6/CompositeGrid/TreeIndentingPlugin.d.ts +2 -1
  132. package/lib/types/es6/CompositeGrid/index.d.ts +9 -9
  133. package/lib/types/es6/ConditionalColoring.d.ts +1 -1
  134. package/lib/types/es6/Core/data/ColumnStats.d.ts +2 -2
  135. package/lib/types/es6/Core/data/DataCache.d.ts +4 -4
  136. package/lib/types/es6/Core/data/DataTable.d.ts +5 -5
  137. package/lib/types/es6/Core/data/DataView.d.ts +12 -12
  138. package/lib/types/es6/Core/data/SegmentCollection.d.ts +3 -3
  139. package/lib/types/es6/Core/data/WrappedView.d.ts +13 -13
  140. package/lib/types/es6/Core/grid/Core.d.ts +29 -27
  141. package/lib/types/es6/Core/grid/ILayoutGrid.d.ts +15 -15
  142. package/lib/types/es6/Core/grid/components/Cell.d.ts +4 -4
  143. package/lib/types/es6/Core/grid/components/CellFloatingPanel.d.ts +1 -1
  144. package/lib/types/es6/Core/grid/components/CellSpans.d.ts +8 -8
  145. package/lib/types/es6/Core/grid/components/Column.d.ts +1 -1
  146. package/lib/types/es6/Core/grid/components/ElementWrapper.d.ts +6 -6
  147. package/lib/types/es6/Core/grid/components/Scrollbar.d.ts +1 -1
  148. package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +14 -6
  149. package/lib/types/es6/Core/grid/util/Conflator.d.ts +2 -2
  150. package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +3 -3
  151. package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +2 -2
  152. package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +1 -1
  153. package/lib/types/es6/Core/grid/util/RangeBar.d.ts +1 -1
  154. package/lib/types/es6/Core/grid/util/SectionSettings.d.ts +5 -5
  155. package/lib/types/es6/Core/grid/util/SelectionList.d.ts +2 -2
  156. package/lib/types/es6/Core/grid/util/TrackLayout.d.ts +7 -3
  157. package/lib/types/es6/Core/grid/util/util.d.ts +2 -2
  158. package/lib/types/es6/Core/index.d.ts +1 -5
  159. package/lib/types/es6/ExtensionOptions.d.ts +2 -0
  160. package/lib/types/es6/InCellEditing.d.ts +7 -4
  161. package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +5 -3
  162. package/lib/types/es6/RealtimeGrid/DataConnector.d.ts +3 -3
  163. package/lib/types/es6/RealtimeGrid/Grid.d.ts +17 -9
  164. package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +19 -0
  165. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +9 -7
  166. package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +3 -1
  167. package/lib/types/es6/RowDragging.d.ts +2 -1
  168. package/lib/types/es6/RowGrouping.d.ts +7 -2
  169. package/lib/types/es6/RowSegmenting.d.ts +7 -2
  170. package/lib/types/es6/TextFormatting.d.ts +1 -1
  171. package/lib/versions.json +14 -13
  172. package/package.json +1 -1
  173. package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
  174. package/lib/core/es6/grid/plugins/DragAndDropTitlePlugin.js +0 -615
  175. package/lib/core/es6/grid/plugins/Plugin.d.ts +0 -28
  176. package/lib/core/es6/grid/plugins/Plugin.js +0 -272
  177. package/lib/types/es6/Core/grid/plugins/DragAndDropTitlePlugin.d.ts +0 -24
  178. package/lib/types/es6/Core/grid/plugins/Plugin.d.ts +0 -28
@@ -1,615 +0,0 @@
1
- /* eslint-disable */
2
- import Ext from "../../../../tr-grid-util/es6/Ext.js";
3
- import Plugin from "./Plugin.js";
4
- import ILayoutGrid from "../ILayoutGrid.js";
5
- import Util from "../util/util.js";
6
- import Core from "../Core.js";
7
- /* eslint-enable */
8
-
9
- /** Event
10
- * @event DragAndDropTitlePlugin#dragged
11
- * @type {MouseEvent}
12
- * @property {*} * Depends on the browser's mouse event arguments
13
- */
14
- /** Event
15
- * @event DragAndDropTitlePlugin#columnMoved
16
- * @property {number} startColumnIndex
17
- * @property {number} destColumnIndex
18
- */
19
-
20
- /** @constructor
21
- * @extends {Plugin}
22
- */
23
- var DragAndDropTitlePlugin = function () {
24
- var _t = this;
25
-
26
- _t._onColumnAdded = _t._onColumnAdded.bind(_t);
27
- _t._onColumnMoved = _t._onColumnMoved.bind(_t);
28
- _t._onColumnRemoved = _t._onColumnRemoved.bind(_t);
29
-
30
- _t._onMouseUp = _t._onMouseUp.bind(_t);
31
- _t._onMouseDown = _t._onMouseDown.bind(_t);
32
-
33
- _t._onDrag = _t._onDrag.bind(_t);
34
- _t._onDragStart = _t._onDragStart.bind(_t);
35
- _t._onDragEnd = _t._onDragEnd.bind(_t);
36
- _t._onDragPulse = _t._onDragPulse.bind(_t);
37
-
38
- _t._hosts = [];
39
-
40
- _t._guideline = document.createElement("svg");
41
- _t._guideline.className = "tr-guideline";
42
- _t._dragbox = document.createElement("svg");
43
- _t._dragbox.className = "tr-dragbox";
44
-
45
- _t._addEvent("dragged"); // drag
46
- _t._addEvent("dragStart");
47
- _t._addEvent("dragInterval");
48
- _t._addEvent("preColumnMoved");
49
- _t._addEvent("columnMoved");
50
-
51
- };
52
- Ext.inherits(DragAndDropTitlePlugin, Plugin);
53
-
54
-
55
- /** @private
56
- * @type {Core}
57
- */
58
- DragAndDropTitlePlugin.prototype._clickedGrid;
59
- /** @private
60
- * @type {ILayoutGrid}
61
- */
62
- DragAndDropTitlePlugin.prototype._clickedSection = null;
63
- /** @private
64
- * @type {number}
65
- */
66
- DragAndDropTitlePlugin.prototype._clickedRow = -1;
67
- /** @private
68
- * @type {!Element}
69
- */
70
- DragAndDropTitlePlugin.prototype._guideline;
71
- /** @private
72
- * @type {!Element}
73
- */
74
- DragAndDropTitlePlugin.prototype._dragbox;
75
- /** @private
76
- * @type {number}
77
- */
78
- DragAndDropTitlePlugin.prototype._timerId = 0;
79
- /** @private
80
- * @type {number}
81
- */
82
- DragAndDropTitlePlugin.prototype._dragPulseId = 0;
83
- /** @private
84
- * @type {Object}
85
- */
86
- DragAndDropTitlePlugin.prototype._pos = null; // Cache of current mouse position
87
- /** @private
88
- * @type {number}
89
- */
90
- DragAndDropTitlePlugin.prototype._cacheLeft = 0;
91
- /** @private
92
- * @type {number}
93
- */
94
- DragAndDropTitlePlugin.prototype._cacheWidth = 0;
95
-
96
- /** @private
97
- * @type {number}
98
- */
99
- DragAndDropTitlePlugin.prototype._startColumn = -1;
100
- /** @private
101
- * @type {number}
102
- */
103
- DragAndDropTitlePlugin.prototype._endColumn = -1;
104
- /** @private
105
- * @type {number}
106
- */
107
- DragAndDropTitlePlugin.prototype._destColumn = -1;
108
- /** @private
109
- * @type {number}
110
- */
111
- DragAndDropTitlePlugin.prototype._leftMovableBorder = -1;
112
- /** @private
113
- * @type {number}
114
- */
115
- DragAndDropTitlePlugin.prototype._rightMovableBorder = -1;
116
- /** @private
117
- * @type {boolean}
118
- */
119
- DragAndDropTitlePlugin.prototype._isDragging = false;
120
- /** @private
121
- * @type {boolean}
122
- */
123
- DragAndDropTitlePlugin.prototype._lockFrozen = false;
124
- /** @private
125
- * @type {boolean}
126
- */
127
- DragAndDropTitlePlugin.prototype._disabled = false;
128
- /** @private
129
- * @type {boolean}
130
- */
131
- DragAndDropTitlePlugin.prototype._noColumnMoving = false;
132
- /** @private
133
- * @type {boolean}
134
- */
135
- DragAndDropTitlePlugin.prototype._noDragBox = false;
136
-
137
-
138
- /** @override */
139
- DragAndDropTitlePlugin.prototype.getName = function () {
140
- return "DragAndDropTitlePlugin"; // Read Only
141
- };
142
- /** @override */
143
- DragAndDropTitlePlugin.prototype.initialize = function (host) {
144
- if(this._hosts.indexOf(host) >= 0) { return; }
145
-
146
- this._hosts.push(host);
147
- host.listen("mousedown", this._onMouseDown);
148
- host.listen("columnAdded", this._onColumnAdded);
149
- host.listen("columnMoved", this._onColumnMoved);
150
- host.listen("columnRemoved", this._onColumnRemoved);
151
-
152
- host.listen("dragstart", Util._preventDefault);
153
- };
154
-
155
- /** @override */
156
- DragAndDropTitlePlugin.prototype.unload = function (host) {
157
- var at = this._hosts.indexOf(host);
158
- if(at < 0) { return; }
159
-
160
- this._hosts.splice(at, 1);
161
- host.unlisten("mousedown", this._onMouseDown);
162
- host.unlisten("columnAdded", this._onColumnAdded);
163
- host.unlisten("columnMoved", this._onColumnMoved);
164
- host.unlisten("columnRemoved", this._onColumnRemoved);
165
- };
166
-
167
- /** Specify column to be processed by this plugin
168
- * @public
169
- * @return {null}
170
- */
171
- DragAndDropTitlePlugin.prototype.getMarker = function () {
172
- return null;
173
- };
174
-
175
- /**
176
- * Lock moving of frozen column. If true is spsecified, dragging is disabled for frozen column.
177
- * @public
178
- * @param {boolean} lock
179
- */
180
- DragAndDropTitlePlugin.prototype.lockFrozenColumn = function(lock) {
181
- this._lockFrozen = lock;
182
- };
183
-
184
- /** Disable this plugin entirely
185
- * @public
186
- * @param {boolean=} opt_disabled
187
- */
188
- DragAndDropTitlePlugin.prototype.disable = function(opt_disabled) {
189
- this._disabled = opt_disabled !== false;
190
- };
191
- /** Disable column moving. Only cursor is showing and events are fired. No real column moving.
192
- * @public
193
- * @param {boolean=} opt_disabled
194
- */
195
- DragAndDropTitlePlugin.prototype.disableMoving = function(opt_disabled) {
196
- this._noColumnMoving = opt_disabled !== false;
197
- };
198
- /** Disable column moving. Only cursor is showing and events are fired. No real column moving.
199
- * @public
200
- * @param {boolean=} opt_disabled
201
- */
202
- DragAndDropTitlePlugin.prototype.disableDragBox = function(opt_disabled) {
203
- this._noDragBox = opt_disabled !== false;
204
- };
205
-
206
- /** @private
207
- * @param {number} colIndex
208
- * @return {boolean}
209
- */
210
- DragAndDropTitlePlugin.prototype._isAllowed = function(colIndex) {
211
- var host = this._clickedGrid || this._hosts[0];
212
- if (host) {
213
- var stationaryIndex = host.getStationaryColumnIndex();
214
- if (stationaryIndex < 0) {
215
- return true;
216
- }
217
- if (colIndex <= stationaryIndex) {
218
- return false;
219
- }
220
- }
221
- return true;
222
- };
223
- /** @private
224
- * @param {Event} e
225
- */
226
- DragAndDropTitlePlugin.prototype._onMouseDown = function (e) {
227
- if(this._disabled) {
228
- return;
229
- }
230
- if(e.shiftKey || e.ctrlKey || e.altKey) {
231
- return; // Ignore mousedown event, if modifier key is detected
232
- }
233
- if(e.button) {
234
- return; // We don't allow drag with middle click (button == 1), or right click (button == 2)
235
- }
236
- if(this._timerId) {
237
- return; // Drag timer is already start
238
- }
239
-
240
- var host = this.getRelativeGrid(e);
241
- if(!host) {
242
- return; // Given event should be within grid element
243
- }
244
-
245
- this._pos = host.getRelativePosition(e);
246
- if (this._pos["hit"] === false) {
247
- return; // Only start dragging when mouse is down on the grid
248
- }
249
-
250
- var section = /** @type{ILayoutGrid} */(this._pos["section"]);
251
- if(!section) {
252
- return; // The section that is not in the target section list cannot be dragged
253
- } else if(this._pos["sectionType"] !== "title") {
254
- return; // Sections other than title section cannot be dragged by default
255
- }
256
-
257
- var colIndex = this._pos["colIndex"];
258
- if(!this._isAllowed(colIndex)) {
259
- return; // The column cannot be dragged
260
- }
261
- if(this._lockFrozen && host.isPinnedColumn(colIndex)) {
262
- return; // If the lock frag is on, frozen columns cannot be dragged
263
- }
264
-
265
- var rowIndex = this._pos["rowIndex"]; // rowIndex may not exist
266
- var movableBorder = this._findMoveableBorder(colIndex, rowIndex - 1, section);
267
- var movingColumns = this._getSpan(colIndex, rowIndex, section);
268
-
269
- this._clickedGrid = host;
270
- this._clickedSection = section;
271
- this._clickedRow = rowIndex;
272
-
273
- this._startColumn = movingColumns["left"];
274
- this._endColumn = movingColumns["right"];
275
- this._leftMovableBorder = movableBorder["left"];
276
- this._rightMovableBorder = movableBorder["right"];
277
- this._destColumn = this._startColumn;
278
-
279
- this._timerId = setTimeout(this._onDragStart, 300);
280
- window.addEventListener("mouseup", this._onMouseUp, false);
281
- };
282
- /** @private
283
- * @param {Object} e
284
- */
285
- DragAndDropTitlePlugin.prototype._onMouseUp = function (e) {
286
- if(this._timerId) {
287
- window.clearTimeout(this._timerId);
288
- window.removeEventListener("mouseup", this._onMouseUp, false);
289
- this._timerId = 0;
290
- this._clearCache();
291
- }
292
- };
293
-
294
- /** @private
295
- */
296
- DragAndDropTitlePlugin.prototype._onDragStart = function () {
297
- if(this._disabled || this._isDragging) { return; }
298
-
299
- if (this._hasListener("dragStart")) {
300
- this._dispatch("dragStart", /** @type{!Object} */(this._pos));
301
- }
302
-
303
- if (this._pos["cancel"]) {
304
- return;
305
- }
306
-
307
- this._timerId = 0;
308
- window.removeEventListener("mouseup", this._onMouseUp, false);
309
-
310
- if(!this._clickedGrid) {
311
- return;
312
- }
313
-
314
- this._isDragging = true;
315
- document.body.classList.add("tr-dragging"); // Prevent text selection
316
- // document.body.classList.add("tr-move-cursor");
317
-
318
- window.addEventListener("mousemove", this._onDrag, false);
319
- window.addEventListener("mouseup", this._onDragEnd, true);
320
-
321
- var host = this._clickedGrid;
322
- var height = host.getHeight();
323
- var sectionBound = this._clickedSection.getBoundingClientRect();
324
- var clickedCellBound = this._clickedSection.getCell(this._startColumn, this._clickedRow).getBoundingClientRect();
325
-
326
- var gridElem = host.getElement();
327
- this._guideline.style.top = (clickedCellBound.top - sectionBound.top) + "px";
328
- this._guideline.style.height = (height - 1) + "px";
329
- this._dragbox.style.height = (height - 33) + "px"; // WARNING: Height could be long
330
- this._dragbox.style.width = this._clickedSection.getColumnWidth(this._startColumn) + "px";
331
-
332
- // TODO: guideline and drag box should be outside of grid area
333
- gridElem.appendChild(this._guideline);
334
-
335
- this._dimCol(true);
336
- this._renderGuideline();
337
-
338
- // For step scrolling // TODO: Merge this logic with DraggableContentPlugin
339
- this._scrollStep = Math.floor(host.getScrollWidth() / 25); // Update the scrollbar first
340
- if(this._scrollStep < 40) {
341
- this._scrollStep = 40;
342
- } else if(this._scrollStep > 400) {
343
- this._scrollStep = 400;
344
- }
345
- var scrollbar = host.getHScrollbar();
346
- this._cacheLeft = scrollbar.getLeft() + 20;
347
- this._cacheWidth = scrollbar.getLeft() + scrollbar.getWidth() - 20;
348
-
349
- this._dragPulseId = window.setInterval(this._onDragPulse, 150); // Start pulse
350
- };
351
- /** @private
352
- * @param {Event} e
353
- */
354
- DragAndDropTitlePlugin.prototype._onDrag = function (e) {
355
- if(!this._isDragging) { return; }
356
-
357
- Util._preventDefault(e);
358
- this._pos = this._clickedGrid.getRelativePosition(e); // Relative to the clicked grid
359
-
360
- var host = this.getRelativeGrid(e);
361
- if (!host || host !== this._clickedGrid) { return; }
362
-
363
- var colIndex = this._pos["colIndex"];
364
- if ((colIndex >= this._leftMovableBorder) &&
365
- (colIndex <= this._rightMovableBorder) &&
366
- this._isAllowed(colIndex) &&
367
- !(this._lockFrozen && host.isPinnedColumn(colIndex))) {
368
- this._renderGuideline();
369
- this._dispatch("dragged", /** @type{!Object} */(e));
370
- }
371
- this._renderDragBox(e);
372
- };
373
- /** @private
374
- * @param {Event} e
375
- */
376
- DragAndDropTitlePlugin.prototype._onDragEnd = function (e) {
377
- if(!this._isDragging) {
378
- return;
379
- }
380
-
381
- this._isDragging = false;
382
- document.body.classList.remove("tr-dragging");
383
- // document.body.classList.remove("tr-move-cursor");
384
- this._dimCol(false);
385
-
386
- var pn = this._guideline.parentNode;
387
- if(pn) {
388
- pn.removeChild(this._guideline);
389
- }
390
-
391
- pn = this._dragbox.parentNode;
392
- if(pn) {
393
- pn.removeChild(this._dragbox);
394
- }
395
-
396
- window.removeEventListener("mousemove", this._onDrag, false);
397
- window.removeEventListener("mouseup", this._onDragEnd, true);
398
-
399
- if(this._dragPulseId) {
400
- window.clearInterval(this._dragPulseId);
401
- this._dragPulseId = 0;
402
- }
403
- this._pos = null;
404
-
405
- Util._preventDefault(e);
406
-
407
- //When move to the right, the first position is the current one.
408
- if (this._destColumn > this._startColumn) {
409
- --this._destColumn;
410
- }
411
- //Cancel moving if the destination column is the current column or not allowed column
412
- if ((!this._destColumn && this._destColumn !== 0) || // undefined, NaN, null
413
- this._destColumn < 0 ||
414
- !this._isAllowed(this._destColumn) ||
415
- (this._destColumn >= this._startColumn && this._destColumn <= this._endColumn)) {
416
- this._clearCache();
417
- return;
418
- }
419
-
420
- var arg = {
421
- "startColumnIndex": this._startColumn,
422
- "destColumnIndex": this._destColumn
423
- };
424
-
425
- if (this._hasListener("preColumnMoved")) {
426
- this._dispatch("preColumnMoved", arg);
427
- }
428
-
429
- if (arg["cancel"]) {
430
- return;
431
- }
432
-
433
- if (!this._noColumnMoving) {
434
- var shiftStart = -1;
435
- var shiftEnd = -1;
436
- var moveSize = -1;
437
- if (this._startColumn > this._destColumn) { //Move backward
438
- shiftStart = this._destColumn;
439
- shiftEnd = this._startColumn - 1;
440
- moveSize = -1 * (this._startColumn - this._destColumn); //Move to the left
441
- } else
442
- if (this._startColumn < this._destColumn) { //Move foward
443
- shiftStart = this._endColumn + 1;
444
- shiftEnd = this._destColumn;
445
- moveSize = ((shiftEnd - shiftStart) + 1); //Move to the right
446
- }
447
-
448
- //Perform moving all columns in the range
449
- for(var j = this._hosts.length; --j >= 0;) {
450
- var host = this._hosts[j];
451
- var i;
452
- if (moveSize > 0) { //Move forward
453
- for (i = this._startColumn; i <= this._endColumn; i++) {
454
- host.moveColumn(this._startColumn, this._destColumn);
455
- }
456
- } else { //Move backward
457
- for (i = this._startColumn; i <= this._endColumn; i++) {
458
- host.moveColumn(this._startColumn + (i - this._startColumn), this._destColumn + (i - this._startColumn));
459
- }
460
- }
461
- }
462
- }
463
-
464
- if (this._hasListener("columnMoved")) {
465
- this._dispatch("columnMoved", {
466
- "startColumnIndex": this._startColumn,
467
- "endColumnIndex": this._endColumn,
468
- "destColumnIndex": this._destColumn,
469
- "clickedRow": this._clickedRow
470
- });
471
- }
472
- this._clearCache();
473
- };
474
-
475
- /** @private
476
- */
477
- DragAndDropTitlePlugin.prototype._onDragPulse = function() {
478
- if(!this._isDragging || !this._pos) { return; }
479
-
480
- this._dispatch("dragInterval", /** @type{!Object} */(this._pos));
481
-
482
- var host = this._clickedGrid;
483
- if(!host || !host.getHScrollbar().isActive()) { return; }
484
-
485
- var x = this._pos["x"];
486
- var scrollVal = 0;
487
- if(x < this._cacheLeft) {
488
- scrollVal = -Math.floor(this._scrollStep * (0.8 + Math.random()));
489
-
490
- } else if(x > this._cacheWidth) {
491
- scrollVal = Math.floor(this._scrollStep * (0.8 + Math.random()));
492
- }
493
-
494
- this._scrollRight(scrollVal);
495
- };
496
- /** @private
497
- */
498
- DragAndDropTitlePlugin.prototype._clearCache = function() {
499
- this._startColumn = this._endColumn = this._destColumn = -1;
500
-
501
- this._leftMovableBorder = this._rightMovableBorder = -1;
502
-
503
- this._clickedRow = -1;
504
- this._clickedSection = this._clickedGrid = null;
505
- };
506
-
507
- /** @private
508
- * @param {number} colIndex
509
- * @param {number} row
510
- * @param {ILayoutGrid} section
511
- * @return {!Object}
512
- */
513
- DragAndDropTitlePlugin.prototype._getSpan = function(colIndex, row, section) {
514
- var cellSpan = section.getCellColSpan(colIndex, row);
515
-
516
- if (cellSpan <= 0) { // The specified cell is being occupied
517
- colIndex += cellSpan; // Convert the given negative index to the spanning cell
518
- cellSpan = section.getCellColSpan(colIndex, row);
519
- }
520
-
521
- return { "left": colIndex, "right": (colIndex + cellSpan - 1) };
522
- };
523
- /** @private
524
- * @param {number} col
525
- * @param {number} row
526
- * @param {ILayoutGrid} section
527
- * @return {!Object}
528
- */
529
- DragAndDropTitlePlugin.prototype._findMoveableBorder = function(col, row, section) {
530
- if (row < 0 || (!row && row !== 0)) { // Guaranteed to get out of infinite loop by checking undefined, NaN, null
531
- return { "left": 0, "right": (section.getColumnCount() - 1) };
532
- }
533
- var span = this._getSpan(col, row, section);
534
- if (span["right"] >= span["left"]) {
535
- return span;
536
- } else {
537
- return this._findMoveableBorder(col, row - 1, section);
538
- }
539
- };
540
- /**
541
- * @private
542
- */
543
- DragAndDropTitlePlugin.prototype._renderGuideline = function() {
544
- var colIndex = this._pos["colIndex"];
545
- if(colIndex == null || colIndex < 0) { // undefined, null or negative number
546
- return;
547
- }
548
-
549
- var currentSpan = this._getSpan(colIndex, this._clickedRow, this._clickedSection);
550
- var colStart = currentSpan["left"]; // This can be different from colIndex
551
- var colEnd = currentSpan["right"];
552
- var colLeft = this._clickedGrid.getColumnLeft(colStart);
553
- var colWidth = 0;
554
- for(var i = colStart; i <= colEnd; ++i) {
555
- colWidth += this._clickedGrid.getColumnWidth(i);
556
- }
557
-
558
- var rightHand = this._pos["x"] > colLeft + colWidth / 2;
559
- var destColumn = (rightHand) ? colEnd + 1 : colStart;
560
-
561
- colLeft = this._clickedGrid.getColumnLeft(this._destColumn);
562
- // If destination exceeds the specified bounds
563
- if (destColumn < this._leftMovableBorder) {
564
- destColumn = this._leftMovableBorder;
565
- } else if (destColumn > this._rightMovableBorder) {
566
- destColumn = this._rightMovableBorder + 1;
567
- if(rightHand) {
568
- colLeft -= 4; // Shift guideline to the left if this is the rightmost column
569
- }
570
- }
571
-
572
- this._destColumn = destColumn;
573
- this._guideline.style.left = colLeft + "px";
574
- };
575
- /** @private
576
- * @param {!Element|Event|MouseEvent} e
577
- */
578
- DragAndDropTitlePlugin.prototype._renderDragBox = function(e) {
579
- if(this._noDragBox) {
580
- return;
581
- }
582
-
583
- var gridElem = this._clickedGrid.getElement();
584
- var pn = this._dragbox.parentNode;
585
- if(!pn) {
586
- gridElem.appendChild(this._dragbox);
587
- }
588
-
589
- var gridRect = gridElem.getBoundingClientRect();
590
- var zoomFactor = this._clickedGrid["zoomFactor"]; // TODO: Remove zoom factor
591
- var contentWidth = gridRect.width;
592
-
593
- var x = e.clientX - gridRect.left;
594
- var y = ((e.pageY - gridRect.top) / zoomFactor) - window.scrollY;
595
- var midFactor = parseFloat((x / contentWidth).toFixed(2));
596
- var dragboxLeft = (gridRect.width * midFactor) / zoomFactor - this._dragbox.offsetWidth * midFactor;
597
-
598
- this._dragbox.style.left = dragboxLeft + "px";
599
- this._dragbox.style.top = (y + 10) + "px";
600
- };
601
-
602
- /**
603
- * @private
604
- * @param {boolean} inOut
605
- */
606
- DragAndDropTitlePlugin.prototype._dimCol = function(inOut) {
607
- for (var i = this._startColumn; i <= this._endColumn; i++) {
608
- this._clickedGrid.enableColumnClass(i, "drag-fadeout", inOut);
609
- }
610
- };
611
-
612
- DragAndDropTitlePlugin._proto = DragAndDropTitlePlugin.prototype;
613
-
614
- export default DragAndDropTitlePlugin;
615
- export { DragAndDropTitlePlugin };
@@ -1,28 +0,0 @@
1
- import Ext from "../../../../tr-grid-util/es6/Ext.js";
2
- import Util from "../util/util.js";
3
- import Core from "../Core.js"; // eslint-disable-line
4
- import EventDispatcher from "../event/EventDispatcher.js";
5
- import ElementWrapper from "../components/ElementWrapper.js"; // eslint-disable-line
6
-
7
- declare class Plugin extends EventDispatcher {
8
-
9
- constructor();
10
-
11
- public getName(): string;
12
-
13
- public initialize(owner: Core): void;
14
-
15
- public unload(owner: Core): void;
16
-
17
- public getRelativeGrid(e: Event|Element|ElementWrapper): Core;
18
-
19
- public getGridElementFromPoint(x: number, y: number): Element;
20
-
21
- }
22
-
23
- declare function gridAPI(x: number, y: number): Element;
24
-
25
- declare function to(e: any): void;
26
-
27
- export default Plugin;
28
- export { Plugin };