tabulator-tables 5.4.2 → 5.4.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 (253) hide show
  1. package/.babelrc.json +3 -3
  2. package/.editorconfig +6 -6
  3. package/.eslintignore +3 -3
  4. package/.eslintrc.js +28 -28
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +58 -58
  6. package/.github/ISSUE_TEMPLATE/documentation.md +14 -14
  7. package/.github/ISSUE_TEMPLATE/feature_request.md +24 -24
  8. package/.github/ISSUE_TEMPLATE/question.md +12 -12
  9. package/.github/workflows/bad-files-check.yml +39 -39
  10. package/.github/workflows/lint-and-test.yml +30 -30
  11. package/CODE_OF_CONDUCT.md +46 -46
  12. package/CONTRIBUTING.md +22 -22
  13. package/LICENSE +20 -20
  14. package/README.md +76 -76
  15. package/bower.json +40 -40
  16. package/build/Bundler.js +185 -185
  17. package/build/rollup.js +6 -6
  18. package/dist/css/tabulator.css +1 -5
  19. package/dist/css/tabulator.css.map +1 -1
  20. package/dist/css/tabulator.min.css +1 -1
  21. package/dist/css/tabulator.min.css.map +1 -1
  22. package/dist/css/tabulator_bootstrap3.css +1 -5
  23. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  24. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  25. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  26. package/dist/css/tabulator_bootstrap4.css +1 -5
  27. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  28. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  29. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  30. package/dist/css/tabulator_bootstrap5.css +1 -5
  31. package/dist/css/tabulator_bootstrap5.css.map +1 -1
  32. package/dist/css/tabulator_bootstrap5.min.css +1 -1
  33. package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
  34. package/dist/css/tabulator_bulma.css +1 -5
  35. package/dist/css/tabulator_bulma.css.map +1 -1
  36. package/dist/css/tabulator_bulma.min.css +1 -1
  37. package/dist/css/tabulator_bulma.min.css.map +1 -1
  38. package/dist/css/tabulator_materialize.css +1 -5
  39. package/dist/css/tabulator_materialize.css.map +1 -1
  40. package/dist/css/tabulator_materialize.min.css +1 -1
  41. package/dist/css/tabulator_materialize.min.css.map +1 -1
  42. package/dist/css/tabulator_midnight.css +1 -5
  43. package/dist/css/tabulator_midnight.css.map +1 -1
  44. package/dist/css/tabulator_midnight.min.css +1 -1
  45. package/dist/css/tabulator_midnight.min.css.map +1 -1
  46. package/dist/css/tabulator_modern.css +1 -5
  47. package/dist/css/tabulator_modern.css.map +1 -1
  48. package/dist/css/tabulator_modern.min.css +1 -1
  49. package/dist/css/tabulator_modern.min.css.map +1 -1
  50. package/dist/css/tabulator_semanticui.css +103 -107
  51. package/dist/css/tabulator_semanticui.css.map +1 -1
  52. package/dist/css/tabulator_semanticui.min.css +1 -1
  53. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  54. package/dist/css/tabulator_simple.css +1 -5
  55. package/dist/css/tabulator_simple.css.map +1 -1
  56. package/dist/css/tabulator_simple.min.css +1 -1
  57. package/dist/css/tabulator_simple.min.css.map +1 -1
  58. package/dist/css/tabulator_site.css +1 -5
  59. package/dist/css/tabulator_site.css.map +1 -1
  60. package/dist/css/tabulator_site.min.css +1 -1
  61. package/dist/css/tabulator_site.min.css.map +1 -1
  62. package/dist/js/jquery_wrapper.js +55 -55
  63. package/dist/js/tabulator.js +25847 -25653
  64. package/dist/js/tabulator.js.map +1 -1
  65. package/dist/js/tabulator.min.js +2 -2
  66. package/dist/js/tabulator.min.js.map +1 -1
  67. package/dist/js/tabulator_esm.js +25926 -25732
  68. package/dist/js/tabulator_esm.js.map +1 -1
  69. package/dist/js/tabulator_esm.min.js +2 -2
  70. package/dist/js/tabulator_esm.min.js.map +1 -1
  71. package/package.json +65 -65
  72. package/src/js/builds/esm.js +14 -14
  73. package/src/js/builds/jquery_wrapper.js +55 -55
  74. package/src/js/core/ColumnManager.js +730 -730
  75. package/src/js/core/CoreFeature.js +138 -138
  76. package/src/js/core/FooterManager.js +101 -101
  77. package/src/js/core/Module.js +141 -141
  78. package/src/js/core/RowManager.js +1112 -1082
  79. package/src/js/core/Tabulator.js +895 -893
  80. package/src/js/core/TabulatorFull.js +10 -10
  81. package/src/js/core/cell/Cell.js +295 -295
  82. package/src/js/core/cell/CellComponent.js +76 -76
  83. package/src/js/core/column/Column.js +949 -949
  84. package/src/js/core/column/ColumnComponent.js +152 -152
  85. package/src/js/core/column/defaults/options.js +17 -17
  86. package/src/js/core/defaults/options.js +65 -65
  87. package/src/js/core/modules/core.js +2 -2
  88. package/src/js/core/modules/optional.js +34 -34
  89. package/src/js/core/rendering/Renderer.js +203 -203
  90. package/src/js/core/rendering/renderers/BasicHorizontal.js +19 -19
  91. package/src/js/core/rendering/renderers/BasicVertical.js +79 -78
  92. package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +577 -577
  93. package/src/js/core/rendering/renderers/VirtualDomVertical.js +579 -579
  94. package/src/js/core/row/PseudoRow.js +44 -44
  95. package/src/js/core/row/Row.js +457 -457
  96. package/src/js/core/row/RowComponent.js +93 -93
  97. package/src/js/core/tools/Alert.js +61 -61
  98. package/src/js/core/tools/ComponentFunctionBinder.js +32 -32
  99. package/src/js/core/tools/DataLoader.js +119 -119
  100. package/src/js/core/tools/DeprecationAdvisor.js +46 -46
  101. package/src/js/core/tools/ExternalEventBus.js +104 -104
  102. package/src/js/core/tools/Helpers.js +46 -46
  103. package/src/js/core/tools/InteractionMonitor.js +321 -321
  104. package/src/js/core/tools/InternalEventBus.js +161 -161
  105. package/src/js/core/tools/ModuleBinder.js +104 -104
  106. package/src/js/core/tools/OptionsList.js +44 -40
  107. package/src/js/core/tools/Popup.js +304 -304
  108. package/src/js/core/tools/TableRegistry.js +61 -61
  109. package/src/js/modules/Accessor/Accessor.js +115 -115
  110. package/src/js/modules/Ajax/Ajax.js +143 -143
  111. package/src/js/modules/Ajax/defaults/config.js +2 -2
  112. package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +44 -44
  113. package/src/js/modules/Ajax/defaults/loaderPromise.js +86 -86
  114. package/src/js/modules/Ajax/defaults/urlGenerator.js +43 -43
  115. package/src/js/modules/Clipboard/Clipboard.js +279 -279
  116. package/src/js/modules/Clipboard/defaults/pasteActions.js +10 -10
  117. package/src/js/modules/Clipboard/defaults/pasteParsers.js +74 -74
  118. package/src/js/modules/ColumnCalcs/CalcComponent.js +47 -47
  119. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +581 -568
  120. package/src/js/modules/ColumnCalcs/defaults/calculations.js +85 -85
  121. package/src/js/modules/Comms/Comms.js +51 -51
  122. package/src/js/modules/DataTree/DataTree.js +603 -603
  123. package/src/js/modules/Download/Download.js +148 -148
  124. package/src/js/modules/Download/defaults/downloaders/csv.js +61 -61
  125. package/src/js/modules/Download/defaults/downloaders/html.js +4 -4
  126. package/src/js/modules/Download/defaults/downloaders/json.js +33 -33
  127. package/src/js/modules/Download/defaults/downloaders/jsonLines.js +31 -31
  128. package/src/js/modules/Download/defaults/downloaders/pdf.js +111 -111
  129. package/src/js/modules/Download/defaults/downloaders/xlsx.js +98 -98
  130. package/src/js/modules/Download/defaults/downloaders.js +14 -14
  131. package/src/js/modules/Edit/Edit.js +735 -736
  132. package/src/js/modules/Edit/List.js +1037 -1033
  133. package/src/js/modules/Edit/defaults/editors/autocomplete.js +11 -11
  134. package/src/js/modules/Edit/defaults/editors/date.js +138 -110
  135. package/src/js/modules/Edit/defaults/editors/datetime.js +125 -97
  136. package/src/js/modules/Edit/defaults/editors/input.js +76 -74
  137. package/src/js/modules/Edit/defaults/editors/list.js +6 -6
  138. package/src/js/modules/Edit/defaults/editors/number.js +109 -107
  139. package/src/js/modules/Edit/defaults/editors/progress.js +126 -126
  140. package/src/js/modules/Edit/defaults/editors/range.js +80 -78
  141. package/src/js/modules/Edit/defaults/editors/select.js +9 -9
  142. package/src/js/modules/Edit/defaults/editors/star.js +145 -145
  143. package/src/js/modules/Edit/defaults/editors/textarea.js +122 -120
  144. package/src/js/modules/Edit/defaults/editors/tickCross.js +94 -96
  145. package/src/js/modules/Edit/defaults/editors/time.js +126 -98
  146. package/src/js/modules/Edit/defaults/editors.js +28 -28
  147. package/src/js/modules/Edit/inputMask.js +73 -73
  148. package/src/js/modules/Export/Export.js +623 -617
  149. package/src/js/modules/Export/ExportColumn.js +10 -10
  150. package/src/js/modules/Export/ExportRow.js +9 -9
  151. package/src/js/modules/Filter/Filter.js +892 -889
  152. package/src/js/modules/Filter/defaults/filters.js +107 -107
  153. package/src/js/modules/Format/Format.js +212 -212
  154. package/src/js/modules/Format/defaults/formatters/buttonCross.js +2 -2
  155. package/src/js/modules/Format/defaults/formatters/buttonTick.js +2 -2
  156. package/src/js/modules/Format/defaults/formatters/color.js +3 -3
  157. package/src/js/modules/Format/defaults/formatters/datetime.js +36 -36
  158. package/src/js/modules/Format/defaults/formatters/datetimediff.js +40 -40
  159. package/src/js/modules/Format/defaults/formatters/handle.js +3 -3
  160. package/src/js/modules/Format/defaults/formatters/html.js +2 -2
  161. package/src/js/modules/Format/defaults/formatters/image.js +39 -39
  162. package/src/js/modules/Format/defaults/formatters/link.js +77 -77
  163. package/src/js/modules/Format/defaults/formatters/lookup.js +9 -9
  164. package/src/js/modules/Format/defaults/formatters/money.js +36 -36
  165. package/src/js/modules/Format/defaults/formatters/plaintext.js +2 -2
  166. package/src/js/modules/Format/defaults/formatters/progress.js +132 -132
  167. package/src/js/modules/Format/defaults/formatters/responsiveCollapse.js +43 -43
  168. package/src/js/modules/Format/defaults/formatters/rowSelection.js +59 -59
  169. package/src/js/modules/Format/defaults/formatters/rownum.js +9 -9
  170. package/src/js/modules/Format/defaults/formatters/star.js +37 -37
  171. package/src/js/modules/Format/defaults/formatters/textarea.js +3 -3
  172. package/src/js/modules/Format/defaults/formatters/tickCross.js +21 -21
  173. package/src/js/modules/Format/defaults/formatters/traffic.js +46 -46
  174. package/src/js/modules/Format/defaults/formatters.js +42 -42
  175. package/src/js/modules/FrozenColumns/FrozenColumns.js +299 -299
  176. package/src/js/modules/FrozenRows/FrozenRows.js +169 -159
  177. package/src/js/modules/GroupRows/Group.js +597 -595
  178. package/src/js/modules/GroupRows/GroupComponent.js +66 -66
  179. package/src/js/modules/GroupRows/GroupRows.js +639 -623
  180. package/src/js/modules/History/History.js +171 -171
  181. package/src/js/modules/History/defaults/redoers.js +24 -24
  182. package/src/js/modules/History/defaults/undoers.js +24 -24
  183. package/src/js/modules/HtmlTableImport/HtmlTableImport.js +181 -181
  184. package/src/js/modules/Import/Import.js +193 -193
  185. package/src/js/modules/Import/defaults/importers/array.js +4 -4
  186. package/src/js/modules/Import/defaults/importers/csv.js +62 -62
  187. package/src/js/modules/Import/defaults/importers/json.js +7 -7
  188. package/src/js/modules/Import/defaults/importers.js +8 -8
  189. package/src/js/modules/Interaction/Interaction.js +325 -325
  190. package/src/js/modules/Keybindings/Keybindings.js +172 -172
  191. package/src/js/modules/Keybindings/defaults/actions.js +118 -118
  192. package/src/js/modules/Keybindings/defaults/bindings.js +12 -12
  193. package/src/js/modules/Layout/Layout.js +49 -49
  194. package/src/js/modules/Layout/defaults/modes/fitColumns.js +171 -171
  195. package/src/js/modules/Layout/defaults/modes/fitData.js +9 -9
  196. package/src/js/modules/Layout/defaults/modes/fitDataGeneral.js +9 -9
  197. package/src/js/modules/Layout/defaults/modes/fitDataStretch.js +39 -39
  198. package/src/js/modules/Layout/defaults/modes.js +11 -11
  199. package/src/js/modules/Localize/Localize.js +185 -194
  200. package/src/js/modules/Localize/defaults/langs.js +36 -36
  201. package/src/js/modules/Menu/Menu.js +302 -302
  202. package/src/js/modules/MoveColumns/MoveColumns.js +299 -299
  203. package/src/js/modules/MoveRows/MoveRows.js +635 -635
  204. package/src/js/modules/Mutator/Mutator.js +161 -161
  205. package/src/js/modules/Page/Page.js +881 -881
  206. package/src/js/modules/Page/defaults/pageCounters/pages.js +32 -32
  207. package/src/js/modules/Page/defaults/pageCounters/rows.js +39 -39
  208. package/src/js/modules/Page/defaults/pageCounters.js +7 -7
  209. package/src/js/modules/Persistence/Persistence.js +458 -458
  210. package/src/js/modules/Persistence/defaults/readers.js +29 -29
  211. package/src/js/modules/Persistence/defaults/writers.js +12 -12
  212. package/src/js/modules/Popup/Popup.js +231 -231
  213. package/src/js/modules/Print/Print.js +137 -124
  214. package/src/js/modules/ReactiveData/ReactiveData.js +408 -408
  215. package/src/js/modules/ResizeColumns/ResizeColumns.js +309 -309
  216. package/src/js/modules/ResizeRows/ResizeRows.js +111 -111
  217. package/src/js/modules/ResizeTable/ResizeTable.js +159 -159
  218. package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +345 -345
  219. package/src/js/modules/SelectRow/SelectRow.js +446 -436
  220. package/src/js/modules/Sort/Sort.js +470 -470
  221. package/src/js/modules/Sort/defaults/sorters/alphanum.js +43 -43
  222. package/src/js/modules/Sort/defaults/sorters/array.js +53 -53
  223. package/src/js/modules/Sort/defaults/sorters/boolean.js +6 -6
  224. package/src/js/modules/Sort/defaults/sorters/date.js +9 -9
  225. package/src/js/modules/Sort/defaults/sorters/datetime.js +43 -43
  226. package/src/js/modules/Sort/defaults/sorters/exists.js +6 -6
  227. package/src/js/modules/Sort/defaults/sorters/number.js +39 -39
  228. package/src/js/modules/Sort/defaults/sorters/string.js +33 -33
  229. package/src/js/modules/Sort/defaults/sorters/time.js +9 -9
  230. package/src/js/modules/Sort/defaults/sorters.js +20 -20
  231. package/src/js/modules/Tooltip/Tooltip.js +130 -130
  232. package/src/js/modules/Validate/Validate.js +305 -305
  233. package/src/js/modules/Validate/defaults/validators.js +138 -138
  234. package/src/scss/tabulator.scss +1464 -1466
  235. package/src/scss/themes/bootstrap/functions4.scss +118 -118
  236. package/src/scss/themes/bootstrap/functions5.scss +302 -302
  237. package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +284 -284
  238. package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +544 -544
  239. package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +574 -574
  240. package/src/scss/themes/bootstrap/variables3.scss +870 -870
  241. package/src/scss/themes/bootstrap/variables4.scss +930 -930
  242. package/src/scss/themes/bootstrap/variables5.scss +1641 -1641
  243. package/src/scss/themes/bulma/tabulator_bulma.scss +252 -252
  244. package/src/scss/themes/bulma/variables.scss +197 -197
  245. package/src/scss/themes/materialize/tabulator_materialize.scss +265 -265
  246. package/src/scss/themes/materialize/variables.scss +70 -70
  247. package/src/scss/themes/semanticui/tabulator_semanticui.scss +561 -561
  248. package/src/scss/themes/semanticui/variables.scss +839 -839
  249. package/src/scss/themes/semanticui/variables_table.scss +247 -247
  250. package/src/scss/themes/tabulator_midnight.scss +158 -158
  251. package/src/scss/themes/tabulator_modern.scss +231 -231
  252. package/src/scss/themes/tabulator_simple.scss +102 -102
  253. package/src/scss/themes/tabulator_site.scss +189 -189
@@ -1,457 +1,457 @@
1
- import CoreFeature from '../CoreFeature.js';
2
- import RowComponent from './RowComponent.js';
3
- import Helpers from '../tools/Helpers.js';
4
-
5
- export default class Row extends CoreFeature{
6
- constructor (data, parent, type = "row"){
7
- super(parent.table);
8
-
9
- this.parent = parent;
10
- this.data = {};
11
- this.type = type; //type of element
12
- this.element = false;
13
- this.modules = {}; //hold module variables;
14
- this.cells = [];
15
- this.height = 0; //hold element height
16
- this.heightStyled = ""; //hold element height pre-styled to improve render efficiency
17
- this.manualHeight = false; //user has manually set row height
18
- this.outerHeight = 0; //hold elements outer height
19
- this.initialized = false; //element has been rendered
20
- this.heightInitialized = false; //element has resized cells to fit
21
- this.position = 0; //store position of element in row list
22
- this.positionWatchers = [];
23
-
24
- this.component = null;
25
-
26
- this.created = false;
27
-
28
- this.setData(data);
29
- }
30
-
31
- create(){
32
- if(!this.created){
33
- this.created = true;
34
- this.generateElement();
35
- }
36
- }
37
-
38
- createElement (){
39
- var el = document.createElement("div");
40
-
41
- el.classList.add("tabulator-row");
42
- el.setAttribute("role", "row");
43
-
44
- this.element = el;
45
- }
46
-
47
- getElement(){
48
- this.create();
49
- return this.element;
50
- }
51
-
52
- detachElement(){
53
- if (this.element && this.element.parentNode){
54
- this.element.parentNode.removeChild(this.element);
55
- }
56
- }
57
-
58
- generateElement(){
59
- this.createElement();
60
- this.dispatch("row-init", this);
61
- }
62
-
63
- generateCells(){
64
- this.cells = this.table.columnManager.generateCells(this);
65
- }
66
-
67
- //functions to setup on first render
68
- initialize(force){
69
- this.create();
70
-
71
- if(!this.initialized || force){
72
-
73
- this.deleteCells();
74
-
75
- while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
76
-
77
- this.dispatch("row-layout-before", this);
78
-
79
- this.generateCells();
80
-
81
- this.initialized = true;
82
-
83
- this.table.columnManager.renderer.renderRowCells(this);
84
-
85
- if(force){
86
- this.normalizeHeight();
87
- }
88
-
89
- this.dispatch("row-layout", this);
90
-
91
- if(this.table.options.rowFormatter){
92
- this.table.options.rowFormatter(this.getComponent());
93
- }
94
-
95
- this.dispatch("row-layout-after", this);
96
- }else{
97
- this.table.columnManager.renderer.rerenderRowCells(this);
98
- }
99
- }
100
-
101
- reinitializeHeight(){
102
- this.heightInitialized = false;
103
-
104
- if(this.element && this.element.offsetParent !== null){
105
- this.normalizeHeight(true);
106
- }
107
- }
108
-
109
- deinitialize(){
110
- this.initialized = false;
111
- }
112
-
113
- deinitializeHeight(){
114
- this.heightInitialized = false;
115
- }
116
-
117
- reinitialize(children){
118
- this.initialized = false;
119
- this.heightInitialized = false;
120
-
121
- if(!this.manualHeight){
122
- this.height = 0;
123
- this.heightStyled = "";
124
- }
125
-
126
- if(this.element && this.element.offsetParent !== null){
127
- this.initialize(true);
128
- }
129
-
130
- this.dispatch("row-relayout", this);
131
- }
132
-
133
- //get heights when doing bulk row style calcs in virtual DOM
134
- calcHeight(force){
135
- var maxHeight = 0,
136
- minHeight;
137
-
138
- if(this.table.options.rowHeight){
139
- this.height = this.table.options.rowHeight;
140
- }else{
141
- minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;
142
-
143
- this.cells.forEach(function(cell){
144
- var height = cell.getHeight();
145
- if(height > maxHeight){
146
- maxHeight = height;
147
- }
148
- });
149
-
150
- if(force){
151
- this.height = Math.max(maxHeight, minHeight);
152
- }else{
153
- this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);
154
- }
155
- }
156
-
157
- this.heightStyled = this.height ? this.height + "px" : "";
158
- this.outerHeight = this.element.offsetHeight;
159
- }
160
-
161
- //set of cells
162
- setCellHeight(){
163
- this.cells.forEach(function(cell){
164
- cell.setHeight();
165
- });
166
-
167
- this.heightInitialized = true;
168
- }
169
-
170
- clearCellHeight(){
171
- this.cells.forEach(function(cell){
172
- cell.clearHeight();
173
- });
174
- }
175
-
176
- //normalize the height of elements in the row
177
- normalizeHeight(force){
178
- if(force && !this.table.options.rowHeight){
179
- this.clearCellHeight();
180
- }
181
-
182
- this.calcHeight(force);
183
-
184
- this.setCellHeight();
185
- }
186
-
187
- //set height of rows
188
- setHeight(height, force){
189
- if(this.height != height || force){
190
-
191
- this.manualHeight = true;
192
-
193
- this.height = height;
194
- this.heightStyled = height ? height + "px" : "";
195
-
196
- this.setCellHeight();
197
-
198
- // this.outerHeight = this.element.outerHeight();
199
- this.outerHeight = this.element.offsetHeight;
200
- }
201
- }
202
-
203
- //return rows outer height
204
- getHeight(){
205
- return this.outerHeight;
206
- }
207
-
208
- //return rows outer Width
209
- getWidth(){
210
- return this.element.offsetWidth;
211
- }
212
-
213
- //////////////// Cell Management /////////////////
214
- deleteCell(cell){
215
- var index = this.cells.indexOf(cell);
216
-
217
- if(index > -1){
218
- this.cells.splice(index, 1);
219
- }
220
- }
221
-
222
- //////////////// Data Management /////////////////
223
- setData(data){
224
- this.data = this.chain("row-data-init-before", [this, data], undefined, data);
225
-
226
- this.dispatch("row-data-init-after", this);
227
- }
228
-
229
- //update the rows data
230
- updateData(updatedData){
231
- var visible = this.element && Helpers.elVisible(this.element),
232
- tempData = {},
233
- newRowData;
234
-
235
- return new Promise((resolve, reject) => {
236
-
237
- if(typeof updatedData === "string"){
238
- updatedData = JSON.parse(updatedData);
239
- }
240
-
241
- this.dispatch("row-data-save-before", this);
242
-
243
- if(this.subscribed("row-data-changing")){
244
- tempData = Object.assign(tempData, this.data);
245
- tempData = Object.assign(tempData, updatedData);
246
- }
247
-
248
- newRowData = this.chain("row-data-changing", [this, tempData, updatedData], null, updatedData);
249
-
250
- //set data
251
- for (let attrname in newRowData) {
252
- this.data[attrname] = newRowData[attrname];
253
- }
254
-
255
- this.dispatch("row-data-save-after", this);
256
-
257
- //update affected cells only
258
- for (let attrname in updatedData) {
259
-
260
- let columns = this.table.columnManager.getColumnsByFieldRoot(attrname);
261
-
262
- columns.forEach((column) => {
263
- let cell = this.getCell(column.getField());
264
-
265
- if(cell){
266
- let value = column.getFieldValue(newRowData);
267
- if(cell.getValue() !== value){
268
- cell.setValueProcessData(value);
269
-
270
- if(visible){
271
- cell.cellRendered();
272
- }
273
- }
274
- }
275
- });
276
- }
277
-
278
- //Partial reinitialization if visible
279
- if(visible){
280
- this.normalizeHeight(true);
281
-
282
- if(this.table.options.rowFormatter){
283
- this.table.options.rowFormatter(this.getComponent());
284
- }
285
- }else{
286
- this.initialized = false;
287
- this.height = 0;
288
- this.heightStyled = "";
289
- }
290
-
291
- this.dispatch("row-data-changed", this, visible, updatedData);
292
-
293
- //this.reinitialize();
294
-
295
- this.dispatchExternal("rowUpdated", this.getComponent());
296
-
297
- if(this.subscribedExternal("dataChanged")){
298
- this.dispatchExternal("dataChanged", this.table.rowManager.getData());
299
- }
300
-
301
- resolve();
302
- });
303
- }
304
-
305
- getData(transform){
306
- if(transform){
307
- return this.chain("row-data-retrieve", [this, transform], null, this.data);
308
- }
309
-
310
- return this.data;
311
- }
312
-
313
- getCell(column){
314
- var match = false;
315
-
316
- column = this.table.columnManager.findColumn(column);
317
-
318
- if(!this.initialized){
319
- this.generateCells();
320
- }
321
-
322
- match = this.cells.find(function(cell){
323
- return cell.column === column;
324
- });
325
-
326
- return match;
327
- }
328
-
329
- getCellIndex(findCell){
330
- return this.cells.findIndex(function(cell){
331
- return cell === findCell;
332
- });
333
- }
334
-
335
- findCell(subject){
336
- return this.cells.find((cell) => {
337
- return cell.element === subject;
338
- });
339
- }
340
-
341
- getCells(){
342
- if(!this.initialized){
343
- this.generateCells();
344
- }
345
-
346
- return this.cells;
347
- }
348
-
349
- nextRow(){
350
- var row = this.table.rowManager.nextDisplayRow(this, true);
351
- return row || false;
352
- }
353
-
354
- prevRow(){
355
- var row = this.table.rowManager.prevDisplayRow(this, true);
356
- return row || false;
357
- }
358
-
359
- moveToRow(to, before){
360
- var toRow = this.table.rowManager.findRow(to);
361
-
362
- if(toRow){
363
- this.table.rowManager.moveRowActual(this, toRow, !before);
364
- this.table.rowManager.refreshActiveData("display", false, true);
365
- }else{
366
- console.warn("Move Error - No matching row found:", to);
367
- }
368
- }
369
-
370
- ///////////////////// Actions /////////////////////
371
- delete(){
372
- this.dispatch("row-delete", this);
373
-
374
- this.deleteActual();
375
-
376
- return Promise.resolve();
377
- }
378
-
379
- deleteActual(blockRedraw){
380
- this.detachModules();
381
-
382
- this.table.rowManager.deleteRow(this, blockRedraw);
383
-
384
- this.deleteCells();
385
-
386
- this.initialized = false;
387
- this.heightInitialized = false;
388
- this.element = false;
389
-
390
- this.dispatch("row-deleted", this);
391
- }
392
-
393
- detachModules(){
394
- this.dispatch("row-deleting", this);
395
- }
396
-
397
- deleteCells(){
398
- var cellCount = this.cells.length;
399
-
400
- for(let i = 0; i < cellCount; i++){
401
- this.cells[0].delete();
402
- }
403
- }
404
-
405
- wipe(){
406
- this.detachModules();
407
- this.deleteCells();
408
-
409
- if(this.element){
410
- while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
411
-
412
- if(this.element.parentNode){
413
- this.element.parentNode.removeChild(this.element);
414
- }
415
- }
416
-
417
- this.element = false;
418
- this.modules = {};
419
- }
420
-
421
- isDisplayed(){
422
- return this.table.rowManager.getDisplayRows().includes(this);
423
- }
424
-
425
- getPosition(){
426
- return this.isDisplayed() ? this.position : false;
427
- }
428
-
429
- setPosition(position){
430
- if(position != this.position){
431
- this.position = position;
432
-
433
- this.positionWatchers.forEach((callback) => {
434
- callback(this.position);
435
- });
436
- }
437
- }
438
-
439
- watchPosition(callback){
440
- this.positionWatchers.push(callback);
441
-
442
- callback(this.position);
443
- }
444
-
445
- getGroup(){
446
- return this.modules.group || false;
447
- }
448
-
449
- //////////////// Object Generation /////////////////
450
- getComponent(){
451
- if(!this.component){
452
- this.component = new RowComponent(this);
453
- }
454
-
455
- return this.component;
456
- }
457
- }
1
+ import CoreFeature from '../CoreFeature.js';
2
+ import RowComponent from './RowComponent.js';
3
+ import Helpers from '../tools/Helpers.js';
4
+
5
+ export default class Row extends CoreFeature{
6
+ constructor (data, parent, type = "row"){
7
+ super(parent.table);
8
+
9
+ this.parent = parent;
10
+ this.data = {};
11
+ this.type = type; //type of element
12
+ this.element = false;
13
+ this.modules = {}; //hold module variables;
14
+ this.cells = [];
15
+ this.height = 0; //hold element height
16
+ this.heightStyled = ""; //hold element height pre-styled to improve render efficiency
17
+ this.manualHeight = false; //user has manually set row height
18
+ this.outerHeight = 0; //hold elements outer height
19
+ this.initialized = false; //element has been rendered
20
+ this.heightInitialized = false; //element has resized cells to fit
21
+ this.position = 0; //store position of element in row list
22
+ this.positionWatchers = [];
23
+
24
+ this.component = null;
25
+
26
+ this.created = false;
27
+
28
+ this.setData(data);
29
+ }
30
+
31
+ create(){
32
+ if(!this.created){
33
+ this.created = true;
34
+ this.generateElement();
35
+ }
36
+ }
37
+
38
+ createElement (){
39
+ var el = document.createElement("div");
40
+
41
+ el.classList.add("tabulator-row");
42
+ el.setAttribute("role", "row");
43
+
44
+ this.element = el;
45
+ }
46
+
47
+ getElement(){
48
+ this.create();
49
+ return this.element;
50
+ }
51
+
52
+ detachElement(){
53
+ if (this.element && this.element.parentNode){
54
+ this.element.parentNode.removeChild(this.element);
55
+ }
56
+ }
57
+
58
+ generateElement(){
59
+ this.createElement();
60
+ this.dispatch("row-init", this);
61
+ }
62
+
63
+ generateCells(){
64
+ this.cells = this.table.columnManager.generateCells(this);
65
+ }
66
+
67
+ //functions to setup on first render
68
+ initialize(force){
69
+ this.create();
70
+
71
+ if(!this.initialized || force){
72
+
73
+ this.deleteCells();
74
+
75
+ while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
76
+
77
+ this.dispatch("row-layout-before", this);
78
+
79
+ this.generateCells();
80
+
81
+ this.initialized = true;
82
+
83
+ this.table.columnManager.renderer.renderRowCells(this);
84
+
85
+ if(force){
86
+ this.normalizeHeight();
87
+ }
88
+
89
+ this.dispatch("row-layout", this);
90
+
91
+ if(this.table.options.rowFormatter){
92
+ this.table.options.rowFormatter(this.getComponent());
93
+ }
94
+
95
+ this.dispatch("row-layout-after", this);
96
+ }else{
97
+ this.table.columnManager.renderer.rerenderRowCells(this);
98
+ }
99
+ }
100
+
101
+ reinitializeHeight(){
102
+ this.heightInitialized = false;
103
+
104
+ if(this.element && this.element.offsetParent !== null){
105
+ this.normalizeHeight(true);
106
+ }
107
+ }
108
+
109
+ deinitialize(){
110
+ this.initialized = false;
111
+ }
112
+
113
+ deinitializeHeight(){
114
+ this.heightInitialized = false;
115
+ }
116
+
117
+ reinitialize(children){
118
+ this.initialized = false;
119
+ this.heightInitialized = false;
120
+
121
+ if(!this.manualHeight){
122
+ this.height = 0;
123
+ this.heightStyled = "";
124
+ }
125
+
126
+ if(this.element && this.element.offsetParent !== null){
127
+ this.initialize(true);
128
+ }
129
+
130
+ this.dispatch("row-relayout", this);
131
+ }
132
+
133
+ //get heights when doing bulk row style calcs in virtual DOM
134
+ calcHeight(force){
135
+ var maxHeight = 0,
136
+ minHeight;
137
+
138
+ if(this.table.options.rowHeight){
139
+ this.height = this.table.options.rowHeight;
140
+ }else{
141
+ minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;
142
+
143
+ this.cells.forEach(function(cell){
144
+ var height = cell.getHeight();
145
+ if(height > maxHeight){
146
+ maxHeight = height;
147
+ }
148
+ });
149
+
150
+ if(force){
151
+ this.height = Math.max(maxHeight, minHeight);
152
+ }else{
153
+ this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);
154
+ }
155
+ }
156
+
157
+ this.heightStyled = this.height ? this.height + "px" : "";
158
+ this.outerHeight = this.element.offsetHeight;
159
+ }
160
+
161
+ //set of cells
162
+ setCellHeight(){
163
+ this.cells.forEach(function(cell){
164
+ cell.setHeight();
165
+ });
166
+
167
+ this.heightInitialized = true;
168
+ }
169
+
170
+ clearCellHeight(){
171
+ this.cells.forEach(function(cell){
172
+ cell.clearHeight();
173
+ });
174
+ }
175
+
176
+ //normalize the height of elements in the row
177
+ normalizeHeight(force){
178
+ if(force && !this.table.options.rowHeight){
179
+ this.clearCellHeight();
180
+ }
181
+
182
+ this.calcHeight(force);
183
+
184
+ this.setCellHeight();
185
+ }
186
+
187
+ //set height of rows
188
+ setHeight(height, force){
189
+ if(this.height != height || force){
190
+
191
+ this.manualHeight = true;
192
+
193
+ this.height = height;
194
+ this.heightStyled = height ? height + "px" : "";
195
+
196
+ this.setCellHeight();
197
+
198
+ // this.outerHeight = this.element.outerHeight();
199
+ this.outerHeight = this.element.offsetHeight;
200
+ }
201
+ }
202
+
203
+ //return rows outer height
204
+ getHeight(){
205
+ return this.outerHeight;
206
+ }
207
+
208
+ //return rows outer Width
209
+ getWidth(){
210
+ return this.element.offsetWidth;
211
+ }
212
+
213
+ //////////////// Cell Management /////////////////
214
+ deleteCell(cell){
215
+ var index = this.cells.indexOf(cell);
216
+
217
+ if(index > -1){
218
+ this.cells.splice(index, 1);
219
+ }
220
+ }
221
+
222
+ //////////////// Data Management /////////////////
223
+ setData(data){
224
+ this.data = this.chain("row-data-init-before", [this, data], undefined, data);
225
+
226
+ this.dispatch("row-data-init-after", this);
227
+ }
228
+
229
+ //update the rows data
230
+ updateData(updatedData){
231
+ var visible = this.element && Helpers.elVisible(this.element),
232
+ tempData = {},
233
+ newRowData;
234
+
235
+ return new Promise((resolve, reject) => {
236
+
237
+ if(typeof updatedData === "string"){
238
+ updatedData = JSON.parse(updatedData);
239
+ }
240
+
241
+ this.dispatch("row-data-save-before", this);
242
+
243
+ if(this.subscribed("row-data-changing")){
244
+ tempData = Object.assign(tempData, this.data);
245
+ tempData = Object.assign(tempData, updatedData);
246
+ }
247
+
248
+ newRowData = this.chain("row-data-changing", [this, tempData, updatedData], null, updatedData);
249
+
250
+ //set data
251
+ for (let attrname in newRowData) {
252
+ this.data[attrname] = newRowData[attrname];
253
+ }
254
+
255
+ this.dispatch("row-data-save-after", this);
256
+
257
+ //update affected cells only
258
+ for (let attrname in updatedData) {
259
+
260
+ let columns = this.table.columnManager.getColumnsByFieldRoot(attrname);
261
+
262
+ columns.forEach((column) => {
263
+ let cell = this.getCell(column.getField());
264
+
265
+ if(cell){
266
+ let value = column.getFieldValue(newRowData);
267
+ if(cell.getValue() !== value){
268
+ cell.setValueProcessData(value);
269
+
270
+ if(visible){
271
+ cell.cellRendered();
272
+ }
273
+ }
274
+ }
275
+ });
276
+ }
277
+
278
+ //Partial reinitialization if visible
279
+ if(visible){
280
+ this.normalizeHeight(true);
281
+
282
+ if(this.table.options.rowFormatter){
283
+ this.table.options.rowFormatter(this.getComponent());
284
+ }
285
+ }else{
286
+ this.initialized = false;
287
+ this.height = 0;
288
+ this.heightStyled = "";
289
+ }
290
+
291
+ this.dispatch("row-data-changed", this, visible, updatedData);
292
+
293
+ //this.reinitialize();
294
+
295
+ this.dispatchExternal("rowUpdated", this.getComponent());
296
+
297
+ if(this.subscribedExternal("dataChanged")){
298
+ this.dispatchExternal("dataChanged", this.table.rowManager.getData());
299
+ }
300
+
301
+ resolve();
302
+ });
303
+ }
304
+
305
+ getData(transform){
306
+ if(transform){
307
+ return this.chain("row-data-retrieve", [this, transform], null, this.data);
308
+ }
309
+
310
+ return this.data;
311
+ }
312
+
313
+ getCell(column){
314
+ var match = false;
315
+
316
+ column = this.table.columnManager.findColumn(column);
317
+
318
+ if(!this.initialized && this.cells.length === 0){
319
+ this.generateCells();
320
+ }
321
+
322
+ match = this.cells.find(function(cell){
323
+ return cell.column === column;
324
+ });
325
+
326
+ return match;
327
+ }
328
+
329
+ getCellIndex(findCell){
330
+ return this.cells.findIndex(function(cell){
331
+ return cell === findCell;
332
+ });
333
+ }
334
+
335
+ findCell(subject){
336
+ return this.cells.find((cell) => {
337
+ return cell.element === subject;
338
+ });
339
+ }
340
+
341
+ getCells(){
342
+ if(!this.initialized && this.cells.length === 0){
343
+ this.generateCells();
344
+ }
345
+
346
+ return this.cells;
347
+ }
348
+
349
+ nextRow(){
350
+ var row = this.table.rowManager.nextDisplayRow(this, true);
351
+ return row || false;
352
+ }
353
+
354
+ prevRow(){
355
+ var row = this.table.rowManager.prevDisplayRow(this, true);
356
+ return row || false;
357
+ }
358
+
359
+ moveToRow(to, before){
360
+ var toRow = this.table.rowManager.findRow(to);
361
+
362
+ if(toRow){
363
+ this.table.rowManager.moveRowActual(this, toRow, !before);
364
+ this.table.rowManager.refreshActiveData("display", false, true);
365
+ }else{
366
+ console.warn("Move Error - No matching row found:", to);
367
+ }
368
+ }
369
+
370
+ ///////////////////// Actions /////////////////////
371
+ delete(){
372
+ this.dispatch("row-delete", this);
373
+
374
+ this.deleteActual();
375
+
376
+ return Promise.resolve();
377
+ }
378
+
379
+ deleteActual(blockRedraw){
380
+ this.detachModules();
381
+
382
+ this.table.rowManager.deleteRow(this, blockRedraw);
383
+
384
+ this.deleteCells();
385
+
386
+ this.initialized = false;
387
+ this.heightInitialized = false;
388
+ this.element = false;
389
+
390
+ this.dispatch("row-deleted", this);
391
+ }
392
+
393
+ detachModules(){
394
+ this.dispatch("row-deleting", this);
395
+ }
396
+
397
+ deleteCells(){
398
+ var cellCount = this.cells.length;
399
+
400
+ for(let i = 0; i < cellCount; i++){
401
+ this.cells[0].delete();
402
+ }
403
+ }
404
+
405
+ wipe(){
406
+ this.detachModules();
407
+ this.deleteCells();
408
+
409
+ if(this.element){
410
+ while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
411
+
412
+ if(this.element.parentNode){
413
+ this.element.parentNode.removeChild(this.element);
414
+ }
415
+ }
416
+
417
+ this.element = false;
418
+ this.modules = {};
419
+ }
420
+
421
+ isDisplayed(){
422
+ return this.table.rowManager.getDisplayRows().includes(this);
423
+ }
424
+
425
+ getPosition(){
426
+ return this.isDisplayed() ? this.position : false;
427
+ }
428
+
429
+ setPosition(position){
430
+ if(position != this.position){
431
+ this.position = position;
432
+
433
+ this.positionWatchers.forEach((callback) => {
434
+ callback(this.position);
435
+ });
436
+ }
437
+ }
438
+
439
+ watchPosition(callback){
440
+ this.positionWatchers.push(callback);
441
+
442
+ callback(this.position);
443
+ }
444
+
445
+ getGroup(){
446
+ return this.modules.group || false;
447
+ }
448
+
449
+ //////////////// Object Generation /////////////////
450
+ getComponent(){
451
+ if(!this.component){
452
+ this.component = new RowComponent(this);
453
+ }
454
+
455
+ return this.component;
456
+ }
457
+ }