tabulator-tables 6.5.0 → 6.5.1

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 (222) hide show
  1. package/dist/js/tabulator.js +1 -1
  2. package/dist/js/tabulator.min.js +1 -1
  3. package/dist/js/tabulator_esm.js +1 -1
  4. package/dist/js/tabulator_esm.min.js +1 -1
  5. package/dist/js/tabulator_esm.min.mjs +1 -1
  6. package/dist/js/tabulator_esm.mjs +1 -1
  7. package/package.json +2 -1
  8. package/src/js/builds/esm.js +16 -0
  9. package/src/js/builds/jquery_wrapper.js +63 -0
  10. package/src/js/builds/usd.js +1 -0
  11. package/src/js/core/ColumnManager.js +789 -0
  12. package/src/js/core/CoreFeature.js +140 -0
  13. package/src/js/core/FooterManager.js +102 -0
  14. package/src/js/core/Module.js +140 -0
  15. package/src/js/core/RowManager.js +1140 -0
  16. package/src/js/core/Tabulator.js +928 -0
  17. package/src/js/core/TabulatorFull.js +21 -0
  18. package/src/js/core/cell/Cell.js +299 -0
  19. package/src/js/core/cell/CellComponent.js +79 -0
  20. package/src/js/core/column/Column.js +978 -0
  21. package/src/js/core/column/ColumnComponent.js +151 -0
  22. package/src/js/core/column/defaults/options.js +18 -0
  23. package/src/js/core/defaults/options.js +66 -0
  24. package/src/js/core/modules/core.js +3 -0
  25. package/src/js/core/modules/optional.js +37 -0
  26. package/src/js/core/rendering/Renderer.js +204 -0
  27. package/src/js/core/rendering/renderers/BasicHorizontal.js +27 -0
  28. package/src/js/core/rendering/renderers/BasicVertical.js +103 -0
  29. package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +587 -0
  30. package/src/js/core/rendering/renderers/VirtualDomVertical.js +642 -0
  31. package/src/js/core/row/PseudoRow.js +47 -0
  32. package/src/js/core/row/Row.js +487 -0
  33. package/src/js/core/row/RowComponent.js +94 -0
  34. package/src/js/core/tools/Alert.js +66 -0
  35. package/src/js/core/tools/ComponentFunctionBinder.js +32 -0
  36. package/src/js/core/tools/DataLoader.js +128 -0
  37. package/src/js/core/tools/DependencyRegistry.js +82 -0
  38. package/src/js/core/tools/DeprecationAdvisor.js +51 -0
  39. package/src/js/core/tools/ExternalEventBus.js +105 -0
  40. package/src/js/core/tools/Helpers.js +66 -0
  41. package/src/js/core/tools/InteractionMonitor.js +329 -0
  42. package/src/js/core/tools/InternalEventBus.js +162 -0
  43. package/src/js/core/tools/ModuleBinder.js +153 -0
  44. package/src/js/core/tools/OptionsList.js +45 -0
  45. package/src/js/core/tools/Popup.js +317 -0
  46. package/src/js/core/tools/TableRegistry.js +65 -0
  47. package/src/js/modules/Accessor/Accessor.js +115 -0
  48. package/src/js/modules/Accessor/defaults/accessors.js +5 -0
  49. package/src/js/modules/Ajax/Ajax.js +142 -0
  50. package/src/js/modules/Ajax/defaults/config.js +3 -0
  51. package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +45 -0
  52. package/src/js/modules/Ajax/defaults/loaderPromise.js +87 -0
  53. package/src/js/modules/Ajax/defaults/urlGenerator.js +44 -0
  54. package/src/js/modules/Clipboard/Clipboard.js +282 -0
  55. package/src/js/modules/Clipboard/defaults/pasteActions.js +11 -0
  56. package/src/js/modules/Clipboard/defaults/pasteParsers.js +75 -0
  57. package/src/js/modules/Clipboard/extensions/extensions.js +9 -0
  58. package/src/js/modules/Clipboard/extensions/keybindings/actions.js +9 -0
  59. package/src/js/modules/Clipboard/extensions/keybindings/bindings.js +3 -0
  60. package/src/js/modules/ColumnCalcs/CalcComponent.js +46 -0
  61. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +586 -0
  62. package/src/js/modules/ColumnCalcs/defaults/calculations.js +93 -0
  63. package/src/js/modules/Comms/Comms.js +49 -0
  64. package/src/js/modules/DataTree/DataTree.js +620 -0
  65. package/src/js/modules/Download/Download.js +146 -0
  66. package/src/js/modules/Download/defaults/downloaders/csv.js +61 -0
  67. package/src/js/modules/Download/defaults/downloaders/html.js +5 -0
  68. package/src/js/modules/Download/defaults/downloaders/json.js +34 -0
  69. package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
  70. package/src/js/modules/Download/defaults/downloaders/pdf.js +113 -0
  71. package/src/js/modules/Download/defaults/downloaders/xlsx.js +103 -0
  72. package/src/js/modules/Download/defaults/downloaders.js +15 -0
  73. package/src/js/modules/Edit/Edit.js +845 -0
  74. package/src/js/modules/Edit/List.js +1060 -0
  75. package/src/js/modules/Edit/defaults/editors/adaptable.js +37 -0
  76. package/src/js/modules/Edit/defaults/editors/date.js +144 -0
  77. package/src/js/modules/Edit/defaults/editors/datetime.js +131 -0
  78. package/src/js/modules/Edit/defaults/editors/input.js +77 -0
  79. package/src/js/modules/Edit/defaults/editors/list.js +7 -0
  80. package/src/js/modules/Edit/defaults/editors/number.js +110 -0
  81. package/src/js/modules/Edit/defaults/editors/progress.js +127 -0
  82. package/src/js/modules/Edit/defaults/editors/range.js +81 -0
  83. package/src/js/modules/Edit/defaults/editors/star.js +146 -0
  84. package/src/js/modules/Edit/defaults/editors/textarea.js +123 -0
  85. package/src/js/modules/Edit/defaults/editors/tickCross.js +95 -0
  86. package/src/js/modules/Edit/defaults/editors/time.js +132 -0
  87. package/src/js/modules/Edit/defaults/editors.js +27 -0
  88. package/src/js/modules/Edit/inputMask.js +74 -0
  89. package/src/js/modules/Export/Export.js +654 -0
  90. package/src/js/modules/Export/ExportColumn.js +9 -0
  91. package/src/js/modules/Export/ExportRow.js +8 -0
  92. package/src/js/modules/Export/defaults/columnLookups.js +3 -0
  93. package/src/js/modules/Export/defaults/rowLookups.js +18 -0
  94. package/src/js/modules/Filter/Filter.js +902 -0
  95. package/src/js/modules/Filter/defaults/filters.js +215 -0
  96. package/src/js/modules/Format/Format.js +200 -0
  97. package/src/js/modules/Format/defaults/formatters/adaptable.js +32 -0
  98. package/src/js/modules/Format/defaults/formatters/array.js +30 -0
  99. package/src/js/modules/Format/defaults/formatters/buttonCross.js +3 -0
  100. package/src/js/modules/Format/defaults/formatters/buttonTick.js +3 -0
  101. package/src/js/modules/Format/defaults/formatters/color.js +4 -0
  102. package/src/js/modules/Format/defaults/formatters/datetime.js +39 -0
  103. package/src/js/modules/Format/defaults/formatters/datetimediff.js +43 -0
  104. package/src/js/modules/Format/defaults/formatters/handle.js +4 -0
  105. package/src/js/modules/Format/defaults/formatters/html.js +3 -0
  106. package/src/js/modules/Format/defaults/formatters/image.js +40 -0
  107. package/src/js/modules/Format/defaults/formatters/json.js +12 -0
  108. package/src/js/modules/Format/defaults/formatters/link.js +82 -0
  109. package/src/js/modules/Format/defaults/formatters/lookup.js +10 -0
  110. package/src/js/modules/Format/defaults/formatters/money.js +44 -0
  111. package/src/js/modules/Format/defaults/formatters/plaintext.js +3 -0
  112. package/src/js/modules/Format/defaults/formatters/progress.js +133 -0
  113. package/src/js/modules/Format/defaults/formatters/rownum.js +14 -0
  114. package/src/js/modules/Format/defaults/formatters/star.js +38 -0
  115. package/src/js/modules/Format/defaults/formatters/textarea.js +4 -0
  116. package/src/js/modules/Format/defaults/formatters/tickCross.js +22 -0
  117. package/src/js/modules/Format/defaults/formatters/toggle.js +48 -0
  118. package/src/js/modules/Format/defaults/formatters/traffic.js +47 -0
  119. package/src/js/modules/Format/defaults/formatters.js +47 -0
  120. package/src/js/modules/FrozenColumns/FrozenColumns.js +302 -0
  121. package/src/js/modules/FrozenRows/FrozenRows.js +175 -0
  122. package/src/js/modules/GroupRows/Group.js +615 -0
  123. package/src/js/modules/GroupRows/GroupComponent.js +69 -0
  124. package/src/js/modules/GroupRows/GroupRows.js +636 -0
  125. package/src/js/modules/History/History.js +172 -0
  126. package/src/js/modules/History/defaults/redoers.js +31 -0
  127. package/src/js/modules/History/defaults/undoers.js +33 -0
  128. package/src/js/modules/History/extensions/extensions.js +9 -0
  129. package/src/js/modules/History/extensions/keybindings/actions.js +27 -0
  130. package/src/js/modules/History/extensions/keybindings/bindings.js +4 -0
  131. package/src/js/modules/HtmlTableImport/HtmlTableImport.js +180 -0
  132. package/src/js/modules/Import/Import.js +303 -0
  133. package/src/js/modules/Import/defaults/importers/array.js +3 -0
  134. package/src/js/modules/Import/defaults/importers/csv.js +61 -0
  135. package/src/js/modules/Import/defaults/importers/json.js +8 -0
  136. package/src/js/modules/Import/defaults/importers/xlsx.js +7 -0
  137. package/src/js/modules/Import/defaults/importers.js +11 -0
  138. package/src/js/modules/Interaction/Interaction.js +339 -0
  139. package/src/js/modules/Keybindings/Keybindings.js +198 -0
  140. package/src/js/modules/Keybindings/defaults/actions.js +90 -0
  141. package/src/js/modules/Keybindings/defaults/bindings.js +12 -0
  142. package/src/js/modules/Layout/Layout.js +66 -0
  143. package/src/js/modules/Layout/defaults/modes/fitColumns.js +171 -0
  144. package/src/js/modules/Layout/defaults/modes/fitData.js +10 -0
  145. package/src/js/modules/Layout/defaults/modes/fitDataGeneral.js +10 -0
  146. package/src/js/modules/Layout/defaults/modes/fitDataStretch.js +40 -0
  147. package/src/js/modules/Layout/defaults/modes.js +12 -0
  148. package/src/js/modules/Localize/Localize.js +184 -0
  149. package/src/js/modules/Localize/defaults/langs.js +37 -0
  150. package/src/js/modules/Menu/Menu.js +302 -0
  151. package/src/js/modules/MoveColumns/MoveColumns.js +311 -0
  152. package/src/js/modules/MoveRows/MoveRows.js +604 -0
  153. package/src/js/modules/MoveRows/defaults/receivers.js +30 -0
  154. package/src/js/modules/MoveRows/defaults/senders.js +5 -0
  155. package/src/js/modules/Mutator/Mutator.js +164 -0
  156. package/src/js/modules/Mutator/defaults/mutators.js +1 -0
  157. package/src/js/modules/Page/Page.js +891 -0
  158. package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
  159. package/src/js/modules/Page/defaults/pageCounters/rows.js +40 -0
  160. package/src/js/modules/Page/defaults/pageCounters.js +8 -0
  161. package/src/js/modules/Persistence/Persistence.js +473 -0
  162. package/src/js/modules/Persistence/defaults/readers.js +29 -0
  163. package/src/js/modules/Persistence/defaults/writers.js +13 -0
  164. package/src/js/modules/Popup/Popup.js +227 -0
  165. package/src/js/modules/Print/Print.js +136 -0
  166. package/src/js/modules/ReactiveData/ReactiveData.js +416 -0
  167. package/src/js/modules/ResizeColumns/ResizeColumns.js +365 -0
  168. package/src/js/modules/ResizeRows/ResizeRows.js +145 -0
  169. package/src/js/modules/ResizeTable/ResizeTable.js +158 -0
  170. package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +354 -0
  171. package/src/js/modules/ResponsiveLayout/extensions/extensions.js +9 -0
  172. package/src/js/modules/ResponsiveLayout/extensions/formatters/responsiveCollapse.js +44 -0
  173. package/src/js/modules/SelectRange/Range.js +366 -0
  174. package/src/js/modules/SelectRange/RangeComponent.js +91 -0
  175. package/src/js/modules/SelectRange/SelectRange.js +993 -0
  176. package/src/js/modules/SelectRange/extensions/clipboard/pasteActions.js +45 -0
  177. package/src/js/modules/SelectRange/extensions/clipboard/pasteParsers.js +57 -0
  178. package/src/js/modules/SelectRange/extensions/export/columnLookups.js +11 -0
  179. package/src/js/modules/SelectRange/extensions/export/rowLookups.js +5 -0
  180. package/src/js/modules/SelectRange/extensions/extensions.js +21 -0
  181. package/src/js/modules/SelectRange/extensions/keybindings/actions.js +38 -0
  182. package/src/js/modules/SelectRange/extensions/keybindings/bindings.js +14 -0
  183. package/src/js/modules/SelectRow/SelectRow.js +499 -0
  184. package/src/js/modules/SelectRow/extensions/extensions.js +9 -0
  185. package/src/js/modules/SelectRow/extensions/formatters/rowSelection.js +60 -0
  186. package/src/js/modules/Sort/Sort.js +480 -0
  187. package/src/js/modules/Sort/defaults/sorters/alphanum.js +44 -0
  188. package/src/js/modules/Sort/defaults/sorters/array.js +82 -0
  189. package/src/js/modules/Sort/defaults/sorters/boolean.js +7 -0
  190. package/src/js/modules/Sort/defaults/sorters/date.js +10 -0
  191. package/src/js/modules/Sort/defaults/sorters/datetime.js +48 -0
  192. package/src/js/modules/Sort/defaults/sorters/exists.js +7 -0
  193. package/src/js/modules/Sort/defaults/sorters/number.js +40 -0
  194. package/src/js/modules/Sort/defaults/sorters/string.js +34 -0
  195. package/src/js/modules/Sort/defaults/sorters/time.js +10 -0
  196. package/src/js/modules/Sort/defaults/sorters.js +21 -0
  197. package/src/js/modules/Spreadsheet/GridCalculator.js +64 -0
  198. package/src/js/modules/Spreadsheet/Sheet.js +243 -0
  199. package/src/js/modules/Spreadsheet/SheetComponent.js +59 -0
  200. package/src/js/modules/Spreadsheet/Spreadsheet.js +309 -0
  201. package/src/js/modules/Tooltip/Tooltip.js +128 -0
  202. package/src/js/modules/Validate/Validate.js +303 -0
  203. package/src/js/modules/Validate/defaults/validators.js +150 -0
  204. package/src/scss/tabulator.scss +1693 -0
  205. package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +302 -0
  206. package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +589 -0
  207. package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +979 -0
  208. package/src/scss/themes/bootstrap/variables3.scss +872 -0
  209. package/src/scss/themes/bootstrap/variables4.scss +1059 -0
  210. package/src/scss/themes/bootstrap/variables5.scss +1967 -0
  211. package/src/scss/themes/bulma/tabulator_bulma.scss +316 -0
  212. package/src/scss/themes/bulma/variables.scss +198 -0
  213. package/src/scss/themes/materialize/tabulator_materialize.scss +318 -0
  214. package/src/scss/themes/materialize/variables.scss +71 -0
  215. package/src/scss/themes/semanticui/tabulator_semanticui.scss +623 -0
  216. package/src/scss/themes/semanticui/variables.scss +843 -0
  217. package/src/scss/themes/semanticui/variables_table.scss +248 -0
  218. package/src/scss/themes/tabulator_midnight.scss +235 -0
  219. package/src/scss/themes/tabulator_modern.scss +308 -0
  220. package/src/scss/themes/tabulator_simple.scss +143 -0
  221. package/src/scss/themes/tabulator_site.scss +267 -0
  222. package/src/scss/themes/tabulator_site_dark.scss +496 -0
@@ -0,0 +1,1140 @@
1
+ import CoreFeature from './CoreFeature.js';
2
+ import Row from './row/Row.js';
3
+ import RowComponent from './row/RowComponent.js';
4
+ import Helpers from './tools/Helpers.js';
5
+
6
+ import RendererBasicVertical from './rendering/renderers/BasicVertical.js';
7
+ import RendererVirtualDomVertical from './rendering/renderers/VirtualDomVertical.js';
8
+
9
+ export default class RowManager extends CoreFeature{
10
+
11
+ constructor(table){
12
+ super(table);
13
+
14
+ this.element = this.createHolderElement(); //containing element
15
+ this.tableElement = this.createTableElement(); //table element
16
+ this.heightFixer = this.createTableElement(); //table element
17
+ this.placeholder = null; //placeholder element
18
+ this.placeholderContents = null; //placeholder element
19
+
20
+ this.firstRender = false; //handle first render
21
+ this.renderMode = "virtual"; //current rendering mode
22
+ this.fixedHeight = false; //current rendering mode
23
+
24
+ this.rows = []; //hold row data objects
25
+ this.activeRowsPipeline = []; //hold calculation of active rows
26
+ this.activeRows = []; //rows currently available to on display in the table
27
+ this.activeRowsCount = 0; //count of active rows
28
+
29
+ this.displayRows = []; //rows currently on display in the table
30
+ this.displayRowsCount = 0; //count of display rows
31
+
32
+ this.scrollTop = 0;
33
+ this.scrollLeft = 0;
34
+
35
+ this.redrawBlock = false; //prevent redraws to allow multiple data manipulations before continuing
36
+ this.redrawBlockRestoreConfig = false; //store latest redraw function calls for when redraw is needed
37
+ this.redrawBlockRenderInPosition = false; //store latest redraw function calls for when redraw is needed
38
+
39
+ this.dataPipeline = []; //hold data pipeline tasks
40
+ this.displayPipeline = []; //hold data display pipeline tasks
41
+
42
+ this.scrollbarWidth = 0;
43
+
44
+ this.renderer = null;
45
+ }
46
+
47
+ //////////////// Setup Functions /////////////////
48
+
49
+ createHolderElement (){
50
+ var el = document.createElement("div");
51
+
52
+ el.classList.add("tabulator-tableholder");
53
+ el.setAttribute("tabindex", 0);
54
+ // el.setAttribute("role", "rowgroup");
55
+
56
+ return el;
57
+ }
58
+
59
+ createTableElement (){
60
+ var el = document.createElement("div");
61
+
62
+ el.classList.add("tabulator-table");
63
+ el.setAttribute("role", "rowgroup");
64
+ el.setAttribute("id", "tabulator-table-body");
65
+
66
+ return el;
67
+ }
68
+
69
+ initializePlaceholder(){
70
+ var placeholder = this.table.options.placeholder;
71
+
72
+ if(typeof placeholder === "function"){
73
+ placeholder = placeholder.call(this.table);
74
+ }
75
+
76
+ placeholder = this.chain("placeholder", [placeholder], placeholder, placeholder) || placeholder;
77
+
78
+ //configure placeholder element
79
+ if(placeholder){
80
+ let el = document.createElement("div");
81
+ el.classList.add("tabulator-placeholder");
82
+
83
+ if(typeof placeholder == "string"){
84
+ let contents = document.createElement("div");
85
+ contents.classList.add("tabulator-placeholder-contents");
86
+ contents.innerHTML = placeholder;
87
+
88
+ el.appendChild(contents);
89
+
90
+ this.placeholderContents = contents;
91
+
92
+ }else if(typeof HTMLElement !== "undefined" && placeholder instanceof HTMLElement){
93
+
94
+ el.appendChild(placeholder);
95
+ this.placeholderContents = placeholder;
96
+ }else{
97
+ console.warn("Invalid placeholder provided, must be string or HTML Element", placeholder);
98
+
99
+ this.el = null;
100
+ }
101
+
102
+ this.placeholder = el;
103
+ }
104
+ }
105
+
106
+ //return containing element
107
+ getElement(){
108
+ return this.element;
109
+ }
110
+
111
+ //return table element
112
+ getTableElement(){
113
+ return this.tableElement;
114
+ }
115
+
116
+ initialize(){
117
+ this.initializePlaceholder();
118
+ this.initializeRenderer();
119
+
120
+ //initialize manager
121
+ this.element.appendChild(this.tableElement);
122
+
123
+ this.firstRender = true;
124
+
125
+ //scroll header along with table body
126
+ this.element.addEventListener("scroll", () => {
127
+ var left = this.element.scrollLeft,
128
+ leftDir = this.scrollLeft > left,
129
+ top = this.element.scrollTop,
130
+ topDir = this.scrollTop > top;
131
+
132
+ //handle horizontal scrolling
133
+ if(this.scrollLeft != left){
134
+ this.scrollLeft = left;
135
+
136
+ this.dispatch("scroll-horizontal", left, leftDir);
137
+ this.dispatchExternal("scrollHorizontal", left, leftDir);
138
+
139
+ this._positionPlaceholder();
140
+ }
141
+
142
+ //handle vertical scrolling
143
+ if(this.scrollTop != top){
144
+ this.scrollTop = top;
145
+
146
+ this.renderer.scrollRows(top, topDir);
147
+
148
+ this.dispatch("scroll-vertical", top, topDir);
149
+ this.dispatchExternal("scrollVertical", top, topDir);
150
+ }
151
+ });
152
+ }
153
+
154
+ ////////////////// Row Manipulation //////////////////
155
+ findRow(subject){
156
+ if(typeof subject == "object"){
157
+ if(subject instanceof Row){
158
+ //subject is row element
159
+ return subject;
160
+ }else if(subject instanceof RowComponent){
161
+ //subject is public row component
162
+ return subject._getSelf() || false;
163
+ }else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){
164
+ //subject is a HTML element of the row
165
+ let match = this.rows.find((row) => {
166
+ return row.getElement() === subject;
167
+ });
168
+
169
+ return match || false;
170
+ }else if(subject === null){
171
+ return false;
172
+ }
173
+ }else if(typeof subject == "undefined"){
174
+ return false;
175
+ }else{
176
+ //subject should be treated as the index of the row
177
+ let match = this.rows.find((row) => {
178
+ return row.data[this.table.options.index] == subject;
179
+ });
180
+
181
+ return match || false;
182
+ }
183
+
184
+ //catch all for any other type of input
185
+ return false;
186
+ }
187
+
188
+ getRowFromDataObject(data){
189
+ var match = this.rows.find((row) => {
190
+ return row.data === data;
191
+ });
192
+
193
+ return match || false;
194
+ }
195
+
196
+ getRowFromPosition(position){
197
+ return this.getDisplayRows().find((row) => {
198
+ return row.type === "row" && row.getPosition() === position && row.isDisplayed();
199
+ });
200
+ }
201
+
202
+ scrollToRow(row, position, ifVisible){
203
+ return this.renderer.scrollToRowPosition(row, position, ifVisible);
204
+ }
205
+
206
+ ////////////////// Data Handling //////////////////
207
+ setData(data, renderInPosition, columnsChanged){
208
+ return new Promise((resolve, reject)=>{
209
+ if(renderInPosition && this.getDisplayRows().length){
210
+ if(this.table.options.pagination){
211
+ this._setDataActual(data, true);
212
+ }else{
213
+ this.reRenderInPosition(() => {
214
+ this._setDataActual(data);
215
+ });
216
+ }
217
+ }else{
218
+ if(this.table.options.autoColumns && columnsChanged && this.table.initialized){
219
+ this.table.columnManager.generateColumnsFromRowData(data);
220
+ }
221
+ this.resetScroll();
222
+
223
+ this._setDataActual(data);
224
+ }
225
+
226
+ resolve();
227
+ });
228
+ }
229
+
230
+ _setDataActual(data, renderInPosition){
231
+ this.dispatchExternal("dataProcessing", data);
232
+
233
+ this._wipeElements();
234
+
235
+ if(Array.isArray(data)){
236
+ this.dispatch("data-processing", data);
237
+
238
+ data.forEach((def, i) => {
239
+ if(def && typeof def === "object"){
240
+ var row = new Row(def, this);
241
+ this.rows.push(row);
242
+ }else{
243
+ console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def);
244
+ }
245
+ });
246
+
247
+ this.refreshActiveData(false, false, renderInPosition);
248
+
249
+ this.dispatch("data-processed", data);
250
+ this.dispatchExternal("dataProcessed", data);
251
+ }else{
252
+ console.error("Data Loading Error - Unable to process data due to invalid data type \nExpecting: array \nReceived: ", typeof data, "\nData: ", data);
253
+ }
254
+ }
255
+
256
+ _wipeElements(){
257
+ this.dispatch("rows-wipe");
258
+
259
+ this.destroy();
260
+
261
+ this.adjustTableSize();
262
+
263
+ this.dispatch("rows-wiped");
264
+ }
265
+
266
+ destroy(){
267
+ this.rows.forEach((row) => {
268
+ row.wipe();
269
+ });
270
+
271
+ this.rows = [];
272
+ this.activeRows = [];
273
+ this.activeRowsPipeline = [];
274
+ this.activeRowsCount = 0;
275
+ this.displayRows = [];
276
+ this.displayRowsCount = 0;
277
+ }
278
+
279
+ deleteRow(row, blockRedraw){
280
+ var allIndex = this.rows.indexOf(row),
281
+ activeIndex = this.activeRows.indexOf(row);
282
+
283
+ if(activeIndex > -1){
284
+ this.activeRows.splice(activeIndex, 1);
285
+ }
286
+
287
+ if(allIndex > -1){
288
+ this.rows.splice(allIndex, 1);
289
+ }
290
+
291
+ this.setActiveRows(this.activeRows);
292
+
293
+ this.displayRowIterator((rows) => {
294
+ var displayIndex = rows.indexOf(row);
295
+
296
+ if(displayIndex > -1){
297
+ rows.splice(displayIndex, 1);
298
+ }
299
+ });
300
+
301
+ if(!blockRedraw){
302
+ this.reRenderInPosition();
303
+ }
304
+
305
+ this.regenerateRowPositions();
306
+
307
+ this.dispatchExternal("rowDeleted", row.getComponent());
308
+
309
+ if(!this.displayRowsCount){
310
+ this.tableEmpty();
311
+ }
312
+
313
+ if(this.subscribedExternal("dataChanged")){
314
+ this.dispatchExternal("dataChanged", this.getData());
315
+ }
316
+ }
317
+
318
+ addRow(data, pos, index, blockRedraw){
319
+ var row = this.addRowActual(data, pos, index, blockRedraw);
320
+ return row;
321
+ }
322
+
323
+ //add multiple rows
324
+ addRows(data, pos, index, refreshDisplayOnly){
325
+ var rows = [];
326
+
327
+ return new Promise((resolve, reject) => {
328
+ pos = this.findAddRowPos(pos);
329
+
330
+ if(!Array.isArray(data)){
331
+ data = [data];
332
+ }
333
+
334
+ if((typeof index == "undefined" && pos) || (typeof index !== "undefined" && !pos)){
335
+ data.reverse();
336
+ }
337
+
338
+ data.forEach((item, i) => {
339
+ var row = this.addRow(item, pos, index, true);
340
+ rows.push(row);
341
+ this.dispatch("row-added", row, item, pos, index);
342
+ });
343
+
344
+ this.refreshActiveData(refreshDisplayOnly ? "displayPipeline" : false, false, true);
345
+
346
+ this.regenerateRowPositions();
347
+
348
+ if(this.displayRowsCount){
349
+ this._clearPlaceholder();
350
+ }
351
+
352
+ resolve(rows);
353
+ });
354
+ }
355
+
356
+ findAddRowPos(pos){
357
+ if(typeof pos === "undefined"){
358
+ pos = this.table.options.addRowPos;
359
+ }
360
+
361
+ if(pos === "pos"){
362
+ pos = true;
363
+ }
364
+
365
+ if(pos === "bottom"){
366
+ pos = false;
367
+ }
368
+
369
+ return pos;
370
+ }
371
+
372
+ addRowActual(data, pos, index, blockRedraw){
373
+ var row = data instanceof Row ? data : new Row(data || {}, this),
374
+ top = this.findAddRowPos(pos),
375
+ allIndex = -1,
376
+ activeIndex, chainResult;
377
+
378
+ if(!index){
379
+ chainResult = this.chain("row-adding-position", [row, top], null, {index, top});
380
+
381
+ index = chainResult.index;
382
+ top = chainResult.top;
383
+ }
384
+
385
+ if(typeof index !== "undefined"){
386
+ index = this.findRow(index);
387
+ }
388
+
389
+ index = this.chain("row-adding-index", [row, index, top], null, index);
390
+
391
+ if(index){
392
+ allIndex = this.rows.indexOf(index);
393
+ }
394
+
395
+ if(index && allIndex > -1){
396
+ activeIndex = this.activeRows.indexOf(index);
397
+
398
+ this.displayRowIterator(function(rows){
399
+ var displayIndex = rows.indexOf(index);
400
+
401
+ if(displayIndex > -1){
402
+ rows.splice((top ? displayIndex : displayIndex + 1), 0, row);
403
+ }
404
+ });
405
+
406
+ if(activeIndex > -1){
407
+ this.activeRows.splice((top ? activeIndex : activeIndex + 1), 0, row);
408
+ }
409
+
410
+ this.rows.splice((top ? allIndex : allIndex + 1), 0, row);
411
+
412
+ }else{
413
+
414
+ if(top){
415
+
416
+ this.displayRowIterator(function(rows){
417
+ rows.unshift(row);
418
+ });
419
+
420
+ this.activeRows.unshift(row);
421
+ this.rows.unshift(row);
422
+ }else{
423
+ this.displayRowIterator(function(rows){
424
+ rows.push(row);
425
+ });
426
+
427
+ this.activeRows.push(row);
428
+ this.rows.push(row);
429
+ }
430
+ }
431
+
432
+ this.setActiveRows(this.activeRows);
433
+
434
+ this.dispatchExternal("rowAdded", row.getComponent());
435
+
436
+ if(this.subscribedExternal("dataChanged")){
437
+ this.dispatchExternal("dataChanged", this.table.rowManager.getData());
438
+ }
439
+
440
+ if(!blockRedraw){
441
+ this.reRenderInPosition();
442
+ }
443
+
444
+ return row;
445
+ }
446
+
447
+ moveRow(from, to, after){
448
+ this.dispatch("row-move", from, to, after);
449
+
450
+ this.moveRowActual(from, to, after);
451
+
452
+ this.regenerateRowPositions();
453
+
454
+ this.dispatch("row-moved", from, to, after);
455
+ this.dispatchExternal("rowMoved", from.getComponent());
456
+ }
457
+
458
+ moveRowActual(from, to, after){
459
+ this.moveRowInArray(this.rows, from, to, after);
460
+ this.moveRowInArray(this.activeRows, from, to, after);
461
+
462
+ this.displayRowIterator((rows) => {
463
+ this.moveRowInArray(rows, from, to, after);
464
+ });
465
+
466
+ this.dispatch("row-moving", from, to, after);
467
+ }
468
+
469
+ moveRowInArray(rows, from, to, after){
470
+ var fromIndex, toIndex, start, end;
471
+
472
+ if(from !== to){
473
+
474
+ fromIndex = rows.indexOf(from);
475
+
476
+ if (fromIndex > -1) {
477
+
478
+ rows.splice(fromIndex, 1);
479
+
480
+ toIndex = rows.indexOf(to);
481
+
482
+ if (toIndex > -1) {
483
+
484
+ if(after){
485
+ rows.splice(toIndex+1, 0, from);
486
+ }else{
487
+ rows.splice(toIndex, 0, from);
488
+ }
489
+
490
+ }else{
491
+ rows.splice(fromIndex, 0, from);
492
+ }
493
+ }
494
+
495
+ //restyle rows
496
+ if(rows === this.getDisplayRows()){
497
+
498
+ start = fromIndex < toIndex ? fromIndex : toIndex;
499
+ end = toIndex > fromIndex ? toIndex : fromIndex +1;
500
+
501
+ for(let i = start; i <= end; i++){
502
+ if(rows[i]){
503
+ this.styleRow(rows[i], i);
504
+ }
505
+ }
506
+ }
507
+ }
508
+ }
509
+
510
+ clearData(){
511
+ this.setData([]);
512
+ }
513
+
514
+ getRowIndex(row){
515
+ return this.findRowIndex(row, this.rows);
516
+ }
517
+
518
+ getDisplayRowIndex(row){
519
+ var index = this.getDisplayRows().indexOf(row);
520
+ return index > -1 ? index : false;
521
+ }
522
+
523
+ nextDisplayRow(row, rowOnly){
524
+ var index = this.getDisplayRowIndex(row),
525
+ nextRow = false;
526
+
527
+
528
+ if(index !== false && index < this.displayRowsCount -1){
529
+ nextRow = this.getDisplayRows()[index+1];
530
+ }
531
+
532
+ if(nextRow && (!(nextRow instanceof Row) || nextRow.type != "row")){
533
+ return this.nextDisplayRow(nextRow, rowOnly);
534
+ }
535
+
536
+ return nextRow;
537
+ }
538
+
539
+ prevDisplayRow(row, rowOnly){
540
+ var index = this.getDisplayRowIndex(row),
541
+ prevRow = false;
542
+
543
+ if(index){
544
+ prevRow = this.getDisplayRows()[index-1];
545
+ }
546
+
547
+ if(rowOnly && prevRow && (!(prevRow instanceof Row) || prevRow.type != "row")){
548
+ return this.prevDisplayRow(prevRow, rowOnly);
549
+ }
550
+
551
+ return prevRow;
552
+ }
553
+
554
+ findRowIndex(row, list){
555
+ var rowIndex;
556
+
557
+ row = this.findRow(row);
558
+
559
+ if(row){
560
+ rowIndex = list.indexOf(row);
561
+
562
+ if(rowIndex > -1){
563
+ return rowIndex;
564
+ }
565
+ }
566
+
567
+ return false;
568
+ }
569
+
570
+ getData(active, transform){
571
+ var output = [],
572
+ rows = this.getRows(active);
573
+
574
+ rows.forEach(function(row){
575
+ if(row.type == "row"){
576
+ output.push(row.getData(transform || "data"));
577
+ }
578
+ });
579
+
580
+ return output;
581
+ }
582
+
583
+ getComponents(active){
584
+ var output = [],
585
+ rows = this.getRows(active);
586
+
587
+ rows.forEach(function(row){
588
+ output.push(row.getComponent());
589
+ });
590
+
591
+ return output;
592
+ }
593
+
594
+ getDataCount(active){
595
+ var rows = this.getRows(active);
596
+
597
+ return rows.length;
598
+ }
599
+
600
+ scrollHorizontal(left){
601
+ this.scrollLeft = left;
602
+ this.element.scrollLeft = left;
603
+
604
+ this.dispatch("scroll-horizontal", left);
605
+ }
606
+
607
+ registerDataPipelineHandler(handler, priority){
608
+ if(typeof priority !== "undefined"){
609
+ this.dataPipeline.push({handler, priority});
610
+ this.dataPipeline.sort((a, b) => {
611
+ return a.priority - b.priority;
612
+ });
613
+ }else{
614
+ console.error("Data pipeline handlers must have a priority in order to be registered");
615
+ }
616
+ }
617
+
618
+ registerDisplayPipelineHandler(handler, priority){
619
+ if(typeof priority !== "undefined"){
620
+ this.displayPipeline.push({handler, priority});
621
+ this.displayPipeline.sort((a, b) => {
622
+ return a.priority - b.priority;
623
+ });
624
+ }else{
625
+ console.error("Display pipeline handlers must have a priority in order to be registered");
626
+ }
627
+ }
628
+
629
+ //set active data set
630
+ refreshActiveData(handler, skipStage, renderInPosition){
631
+ var table = this.table,
632
+ stage = "",
633
+ index = 0,
634
+ cascadeOrder = ["all", "dataPipeline", "display", "displayPipeline", "end"];
635
+
636
+ if(!this.table.destroyed){
637
+ if(typeof handler === "function"){
638
+ index = this.dataPipeline.findIndex((item) => {
639
+ return item.handler === handler;
640
+ });
641
+
642
+ if(index > -1){
643
+ stage = "dataPipeline";
644
+
645
+ if(skipStage){
646
+ if(index == this.dataPipeline.length - 1){
647
+ stage = "display";
648
+ }else{
649
+ index++;
650
+ }
651
+ }
652
+ }else{
653
+ index = this.displayPipeline.findIndex((item) => {
654
+ return item.handler === handler;
655
+ });
656
+
657
+ if(index > -1){
658
+ stage = "displayPipeline";
659
+
660
+ if(skipStage){
661
+ if(index == this.displayPipeline.length - 1){
662
+ stage = "end";
663
+ }else{
664
+ index++;
665
+ }
666
+ }
667
+ }else{
668
+ console.error("Unable to refresh data, invalid handler provided", handler);
669
+ return;
670
+ }
671
+ }
672
+ }else{
673
+ stage = handler || "all";
674
+ index = 0;
675
+ }
676
+
677
+ if(this.redrawBlock){
678
+ if(!this.redrawBlockRestoreConfig || (this.redrawBlockRestoreConfig && ((this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index) || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))))){
679
+ this.redrawBlockRestoreConfig = {
680
+ handler: handler,
681
+ skipStage: skipStage,
682
+ renderInPosition: renderInPosition,
683
+ stage:stage,
684
+ index:index,
685
+ };
686
+ }
687
+
688
+ return;
689
+ }else{
690
+ if(Helpers.elVisible(this.element)){
691
+ if(renderInPosition){
692
+ this.reRenderInPosition(this.refreshPipelines.bind(this, handler, stage, index, renderInPosition));
693
+ }else{
694
+ this.refreshPipelines(handler, stage, index, renderInPosition);
695
+
696
+ if(!handler){
697
+ this.table.columnManager.renderer.renderColumns();
698
+ }
699
+
700
+ this.renderTable();
701
+
702
+ if(table.options.layoutColumnsOnNewData){
703
+ this.table.columnManager.redraw(true);
704
+ }
705
+ }
706
+ }else{
707
+ this.refreshPipelines(handler, stage, index, renderInPosition);
708
+ }
709
+
710
+ this.dispatch("data-refreshed");
711
+ }
712
+ }
713
+ }
714
+
715
+ refreshPipelines(handler, stage, index, renderInPosition){
716
+ this.dispatch("data-refreshing");
717
+
718
+ if(!handler || !this.activeRowsPipeline[0]){
719
+ this.activeRowsPipeline[0] = this.rows.slice(0);
720
+ }
721
+
722
+ //cascade through data refresh stages
723
+ switch(stage){
724
+ case "all":
725
+ //handle case where all data needs refreshing
726
+
727
+ case "dataPipeline":
728
+ for(let i = index; i < this.dataPipeline.length; i++){
729
+ let result = this.dataPipeline[i].handler(this.activeRowsPipeline[i].slice(0));
730
+
731
+ this.activeRowsPipeline[i + 1] = result || this.activeRowsPipeline[i].slice(0);
732
+ }
733
+
734
+ this.setActiveRows(this.activeRowsPipeline[this.dataPipeline.length]);
735
+
736
+ case "display":
737
+ index = 0;
738
+ this.resetDisplayRows();
739
+
740
+ case "displayPipeline":
741
+ for(let i = index; i < this.displayPipeline.length; i++){
742
+ let result = this.displayPipeline[i].handler((i ? this.getDisplayRows(i - 1) : this.activeRows).slice(0), renderInPosition);
743
+
744
+ this.setDisplayRows(result || this.getDisplayRows(i - 1).slice(0), i);
745
+ }
746
+
747
+ case "end":
748
+ //case to handle scenario when trying to skip past end stage
749
+ this.regenerateRowPositions();
750
+ }
751
+
752
+ if(this.getDisplayRows().length){
753
+ this._clearPlaceholder();
754
+ }
755
+ }
756
+
757
+ //regenerate row positions
758
+ regenerateRowPositions(){
759
+ var rows = this.getDisplayRows();
760
+ var index = 1;
761
+
762
+ rows.forEach((row) => {
763
+ if (row.type === "row"){
764
+ row.setPosition(index);
765
+ index++;
766
+ }
767
+ });
768
+ }
769
+
770
+ setActiveRows(activeRows){
771
+ this.activeRows = this.activeRows = Object.assign([], activeRows);
772
+ this.activeRowsCount = this.activeRows.length;
773
+ }
774
+
775
+ //reset display rows array
776
+ resetDisplayRows(){
777
+ this.displayRows = [];
778
+
779
+ this.displayRows.push(this.activeRows.slice(0));
780
+
781
+ this.displayRowsCount = this.displayRows[0].length;
782
+ }
783
+
784
+ //set display row pipeline data
785
+ setDisplayRows(displayRows, index){
786
+ this.displayRows[index] = displayRows;
787
+
788
+ if(index == this.displayRows.length -1){
789
+ this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;
790
+ }
791
+ }
792
+
793
+ getDisplayRows(index){
794
+ if(typeof index == "undefined"){
795
+ return this.displayRows.length ? this.displayRows[this.displayRows.length -1] : [];
796
+ }else{
797
+ return this.displayRows[index] || [];
798
+ }
799
+ }
800
+
801
+ getVisibleRows(chain, viewable){
802
+ var rows = Object.assign([], this.renderer.visibleRows(!viewable));
803
+
804
+ if(chain){
805
+ rows = this.chain("rows-visible", [viewable], rows, rows);
806
+ }
807
+
808
+ return rows;
809
+ }
810
+
811
+ //repeat action across display rows
812
+ displayRowIterator(callback){
813
+ this.activeRowsPipeline.forEach(callback);
814
+ this.displayRows.forEach(callback);
815
+
816
+ this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;
817
+ }
818
+
819
+ //return only actual rows (not group headers etc)
820
+ getRows(type){
821
+ var rows = [];
822
+
823
+ switch(type){
824
+ case "active":
825
+ rows = this.activeRows;
826
+ break;
827
+
828
+ case "display":
829
+ rows = this.table.rowManager.getDisplayRows();
830
+ break;
831
+
832
+ case "visible":
833
+ rows = this.getVisibleRows(false, true);
834
+ break;
835
+
836
+ default:
837
+ rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows;
838
+ }
839
+
840
+ return rows;
841
+ }
842
+
843
+ ///////////////// Table Rendering /////////////////
844
+ //trigger rerender of table in current position
845
+ reRenderInPosition(callback){
846
+ if(this.redrawBlock){
847
+ if(callback){
848
+ callback();
849
+ }else{
850
+ this.redrawBlockRenderInPosition = true;
851
+ }
852
+ }else{
853
+ this.dispatchExternal("renderStarted");
854
+
855
+ this.renderer.rerenderRows(callback);
856
+
857
+ if(!this.fixedHeight){
858
+ this.adjustTableSize();
859
+ }
860
+
861
+ this.scrollBarCheck();
862
+
863
+ this.dispatchExternal("renderComplete");
864
+ }
865
+ }
866
+
867
+ scrollBarCheck(){
868
+ var scrollbarWidth = 0;
869
+
870
+ //adjust for vertical scrollbar moving table when present
871
+ if(this.element.scrollHeight > this.element.clientHeight){
872
+ scrollbarWidth = this.element.offsetWidth - this.element.clientWidth;
873
+ }
874
+
875
+ if(scrollbarWidth !== this.scrollbarWidth){
876
+ this.scrollbarWidth = scrollbarWidth;
877
+ this.dispatch("scrollbar-vertical", scrollbarWidth);
878
+ }
879
+ }
880
+
881
+ initializeRenderer(){
882
+ var renderClass;
883
+
884
+ var renderers = {
885
+ "virtual": RendererVirtualDomVertical,
886
+ "basic": RendererBasicVertical,
887
+ };
888
+
889
+ if(typeof this.table.options.renderVertical === "string"){
890
+ renderClass = renderers[this.table.options.renderVertical];
891
+ }else{
892
+ renderClass = this.table.options.renderVertical;
893
+ }
894
+
895
+ if(renderClass){
896
+ this.renderMode = this.table.options.renderVertical;
897
+
898
+ this.renderer = new renderClass(this.table, this.element, this.tableElement);
899
+ this.renderer.initialize();
900
+
901
+ if((this.table.element.clientHeight || this.table.options.height) && !(this.table.options.minHeight && this.table.options.maxHeight)){
902
+ this.fixedHeight = true;
903
+ }else{
904
+ this.fixedHeight = false;
905
+ }
906
+ }else{
907
+ console.error("Unable to find matching renderer:", this.table.options.renderVertical);
908
+ }
909
+ }
910
+
911
+ getRenderMode(){
912
+ return this.renderMode;
913
+ }
914
+
915
+ renderTable(){
916
+ this.dispatchExternal("renderStarted");
917
+
918
+ this.element.scrollTop = 0;
919
+
920
+ this._clearTable();
921
+
922
+ if(this.displayRowsCount){
923
+ this.renderer.renderRows();
924
+
925
+ if(this.firstRender){
926
+ this.firstRender = false;
927
+
928
+ if(!this.fixedHeight){
929
+ this.adjustTableSize();
930
+ }
931
+
932
+ this.layoutRefresh(true);
933
+ }
934
+ }else{
935
+ this.renderEmptyScroll();
936
+ }
937
+
938
+ if(!this.fixedHeight){
939
+ this.adjustTableSize();
940
+ }
941
+
942
+ this.dispatch("table-layout");
943
+
944
+ if(!this.displayRowsCount){
945
+ this._showPlaceholder();
946
+ }
947
+
948
+ this.scrollBarCheck();
949
+
950
+ this.dispatchExternal("renderComplete");
951
+ }
952
+
953
+ //show scrollbars on empty table div
954
+ renderEmptyScroll(){
955
+ if(this.placeholder){
956
+ this.tableElement.style.display = "none";
957
+ }else{
958
+ this.tableElement.style.minWidth = this.table.columnManager.getWidth() + "px";
959
+ // this.tableElement.style.minHeight = "1px";
960
+ // this.tableElement.style.visibility = "hidden";
961
+ }
962
+ }
963
+
964
+ _clearTable(){
965
+ this._clearPlaceholder();
966
+
967
+ this.scrollTop = 0;
968
+ this.scrollLeft = 0;
969
+
970
+ this.renderer.clearRows();
971
+ }
972
+
973
+ tableEmpty(){
974
+ this.renderEmptyScroll();
975
+ this._showPlaceholder();
976
+ }
977
+
978
+ checkPlaceholder(){
979
+ if(this.displayRowsCount){
980
+ this._clearPlaceholder();
981
+ }else{
982
+ this.tableEmpty();
983
+ }
984
+ }
985
+
986
+ _showPlaceholder(){
987
+ if(this.placeholder){
988
+ if(this.placeholder && this.placeholder.parentNode){
989
+ this.placeholder.parentNode.removeChild(this.placeholder);
990
+ }
991
+
992
+ this.initializePlaceholder();
993
+
994
+ this.placeholder.setAttribute("tabulator-render-mode", this.renderMode);
995
+
996
+ this.getElement().appendChild(this.placeholder);
997
+ this._positionPlaceholder();
998
+
999
+ this.adjustTableSize();
1000
+ }
1001
+ }
1002
+
1003
+ _clearPlaceholder(){
1004
+ if(this.placeholder && this.placeholder.parentNode){
1005
+ this.placeholder.parentNode.removeChild(this.placeholder);
1006
+ }
1007
+
1008
+ // clear empty table placeholder min
1009
+ this.tableElement.style.minWidth = "";
1010
+ this.tableElement.style.display = "";
1011
+ }
1012
+
1013
+ _positionPlaceholder(){
1014
+ if(this.placeholder && this.placeholder.parentNode){
1015
+ this.placeholder.style.width = this.table.columnManager.getWidth() + "px";
1016
+ this.placeholderContents.style.width = this.table.rowManager.element.clientWidth + "px";
1017
+ this.placeholderContents.style.marginLeft = this.scrollLeft + "px";
1018
+ }
1019
+ }
1020
+
1021
+ styleRow(row, index){
1022
+ var rowEl = row.getElement();
1023
+
1024
+ if(index % 2){
1025
+ rowEl.classList.add("tabulator-row-even");
1026
+ rowEl.classList.remove("tabulator-row-odd");
1027
+ }else{
1028
+ rowEl.classList.add("tabulator-row-odd");
1029
+ rowEl.classList.remove("tabulator-row-even");
1030
+ }
1031
+ }
1032
+
1033
+ //normalize height of active rows
1034
+ normalizeHeight(force){
1035
+ this.activeRows.forEach(function(row){
1036
+ row.normalizeHeight(force);
1037
+ });
1038
+ }
1039
+
1040
+ //adjust the height of the table holder to fit in the Tabulator element
1041
+ adjustTableSize(){
1042
+ let initialHeight = this.element.clientHeight, minHeight;
1043
+ let resized = false;
1044
+
1045
+ if(this.renderer.verticalFillMode === "fill"){
1046
+ let otherHeight = Math.floor(this.table.columnManager.getElement().getBoundingClientRect().height + (this.table.footerManager && this.table.footerManager.active && !this.table.footerManager.external ? this.table.footerManager.getElement().getBoundingClientRect().height : 0));
1047
+
1048
+ if(this.fixedHeight){
1049
+ minHeight = isNaN(this.table.options.minHeight) ? this.table.options.minHeight : this.table.options.minHeight + "px";
1050
+
1051
+ const height = "calc(100% - " + otherHeight + "px)";
1052
+ this.element.style.minHeight = minHeight || "calc(100% - " + otherHeight + "px)";
1053
+ this.element.style.height = height;
1054
+ this.element.style.maxHeight = height;
1055
+ } else {
1056
+ this.element.style.height = "";
1057
+ this.element.style.height =
1058
+ this.table.element.clientHeight - otherHeight + "px";
1059
+ this.element.scrollTop = this.scrollTop;
1060
+ }
1061
+
1062
+ this.renderer.resize();
1063
+
1064
+ //check if the table has changed size when dealing with variable height tables
1065
+ if(!this.fixedHeight && initialHeight != this.element.clientHeight){
1066
+ resized = true;
1067
+ if(!this.redrawing){ // prevent recursive redraws
1068
+ this.redrawing = true;
1069
+ if(this.subscribed("table-resize")){
1070
+ this.dispatch("table-resize");
1071
+ }else{
1072
+ this.redraw();
1073
+ }
1074
+ this.redrawing = false;
1075
+ }
1076
+ }
1077
+
1078
+ this.scrollBarCheck();
1079
+ }
1080
+
1081
+ this._positionPlaceholder();
1082
+ return resized;
1083
+ }
1084
+
1085
+ //reinitialize all rows
1086
+ reinitialize(){
1087
+ this.rows.forEach(function(row){
1088
+ row.reinitialize(true);
1089
+ });
1090
+ }
1091
+
1092
+ //prevent table from being redrawn
1093
+ blockRedraw (){
1094
+ this.redrawBlock = true;
1095
+ this.redrawBlockRestoreConfig = false;
1096
+ }
1097
+
1098
+ //restore table redrawing
1099
+ restoreRedraw (){
1100
+ this.redrawBlock = false;
1101
+
1102
+ if(this.redrawBlockRestoreConfig){
1103
+ this.refreshActiveData(this.redrawBlockRestoreConfig.handler, this.redrawBlockRestoreConfig.skipStage, this.redrawBlockRestoreConfig.renderInPosition);
1104
+
1105
+ this.redrawBlockRestoreConfig = false;
1106
+ }else{
1107
+ if(this.redrawBlockRenderInPosition){
1108
+ this.reRenderInPosition();
1109
+ }
1110
+ }
1111
+
1112
+ this.redrawBlockRenderInPosition = false;
1113
+ }
1114
+
1115
+ //redraw table
1116
+ redraw (force){
1117
+ this.adjustTableSize();
1118
+ this.table.tableWidth = this.table.element.clientWidth;
1119
+
1120
+ if(!force){
1121
+ this.reRenderInPosition();
1122
+ this.scrollHorizontal(this.scrollLeft);
1123
+ }else{
1124
+ this.renderTable();
1125
+ }
1126
+ }
1127
+
1128
+ resetScroll(){
1129
+ this.element.scrollLeft = 0;
1130
+ this.element.scrollTop = 0;
1131
+
1132
+ if(this.table.browser === "ie"){
1133
+ var event = document.createEvent("Event");
1134
+ event.initEvent("scroll", false, true);
1135
+ this.element.dispatchEvent(event);
1136
+ }else{
1137
+ this.element.dispatchEvent(new Event('scroll'));
1138
+ }
1139
+ }
1140
+ }