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,487 @@
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, inFragment){
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, inFragment);
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, inFragment);
98
+ }
99
+ }
100
+
101
+ rendered(){
102
+ this.cells.forEach((cell) => {
103
+ cell.cellRendered();
104
+ });
105
+ }
106
+
107
+ reinitializeHeight(){
108
+ this.heightInitialized = false;
109
+
110
+ if(this.element && this.element.offsetParent !== null){
111
+ this.normalizeHeight(true);
112
+ }
113
+ }
114
+
115
+ deinitialize(){
116
+ this.initialized = false;
117
+ }
118
+
119
+ deinitializeHeight(){
120
+ this.heightInitialized = false;
121
+ }
122
+
123
+ reinitialize(children){
124
+ this.initialized = false;
125
+ this.heightInitialized = false;
126
+
127
+ if(!this.manualHeight){
128
+ this.height = 0;
129
+ this.heightStyled = "";
130
+ }
131
+
132
+ if(this.element && this.element.offsetParent !== null){
133
+ this.initialize(true);
134
+ }
135
+
136
+ this.dispatch("row-relayout", this);
137
+ }
138
+
139
+ //get heights when doing bulk row style calcs in virtual DOM
140
+ calcHeight(force){
141
+ var maxHeight = 0, minHeight = 0;
142
+
143
+ if(this.table.options.rowHeight){
144
+ this.height = this.table.options.rowHeight;
145
+ }else{
146
+ minHeight = this.calcMinHeight();
147
+ maxHeight = this.calcMaxHeight();
148
+
149
+ if(force){
150
+ this.height = Math.max(maxHeight, minHeight);
151
+ }else{
152
+ this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);
153
+ }
154
+ }
155
+
156
+ this.heightStyled = this.height ? this.height + "px" : "";
157
+ this.outerHeight = this.element.offsetHeight;
158
+ }
159
+
160
+ calcMinHeight(){
161
+ return this.table.options.resizableRows ? this.element.clientHeight : 0;
162
+ }
163
+
164
+ calcMaxHeight(){
165
+ var maxHeight = 0;
166
+
167
+ this.cells.forEach(function(cell){
168
+ var height = cell.getHeight();
169
+
170
+ if(height > maxHeight){
171
+ maxHeight = height;
172
+ }
173
+ });
174
+
175
+ return maxHeight;
176
+ }
177
+
178
+ //set of cells
179
+ setCellHeight(){
180
+ this.cells.forEach(function(cell){
181
+ cell.setHeight();
182
+ });
183
+
184
+ this.heightInitialized = true;
185
+ }
186
+
187
+ clearCellHeight(){
188
+ this.cells.forEach(function(cell){
189
+ cell.clearHeight();
190
+ });
191
+ }
192
+
193
+ //normalize the height of elements in the row
194
+ normalizeHeight(force){
195
+ if(force && !this.table.options.rowHeight){
196
+ this.clearCellHeight();
197
+ }
198
+
199
+ this.calcHeight(force);
200
+
201
+ this.setCellHeight();
202
+ }
203
+
204
+ //set height of rows
205
+ setHeight(height, force){
206
+ if(this.height != height || force){
207
+
208
+ this.manualHeight = true;
209
+
210
+ this.height = height;
211
+ this.heightStyled = height ? height + "px" : "";
212
+
213
+ this.setCellHeight();
214
+
215
+ // this.outerHeight = this.element.outerHeight();
216
+ this.outerHeight = this.element.offsetHeight;
217
+
218
+ if(this.subscribedExternal("rowHeight")){
219
+ this.dispatchExternal("rowHeight", this.getComponent());
220
+ }
221
+ }
222
+ }
223
+
224
+ //return rows outer height
225
+ getHeight(){
226
+ return this.outerHeight;
227
+ }
228
+
229
+ //return rows outer Width
230
+ getWidth(){
231
+ return this.element.offsetWidth;
232
+ }
233
+
234
+ //////////////// Cell Management /////////////////
235
+ deleteCell(cell){
236
+ var index = this.cells.indexOf(cell);
237
+
238
+ if(index > -1){
239
+ this.cells.splice(index, 1);
240
+ }
241
+ }
242
+
243
+ //////////////// Data Management /////////////////
244
+ setData(data){
245
+ this.data = this.chain("row-data-init-before", [this, data], undefined, data);
246
+
247
+ this.dispatch("row-data-init-after", this);
248
+ }
249
+
250
+ //update the rows data
251
+ updateData(updatedData){
252
+ var visible = this.element && Helpers.elVisible(this.element),
253
+ tempData = {},
254
+ newRowData;
255
+
256
+ return new Promise((resolve, reject) => {
257
+
258
+ if(typeof updatedData === "string"){
259
+ updatedData = JSON.parse(updatedData);
260
+ }
261
+
262
+ this.dispatch("row-data-save-before", this);
263
+
264
+ if(this.subscribed("row-data-changing")){
265
+ tempData = Object.assign(tempData, this.data);
266
+ tempData = Object.assign(tempData, updatedData);
267
+ }
268
+
269
+ newRowData = this.chain("row-data-changing", [this, tempData, updatedData], null, updatedData);
270
+
271
+ // compute cells to update
272
+ // This must be done prior to updating the row data otherwise uninitialized cells get
273
+ // generated directly with the updated data, which prevents the run of callbacks
274
+ // registered on cells updates (e.g. mutators)
275
+ const cellsToUpdate = [];
276
+ for (let attrname in updatedData) {
277
+
278
+ let columns = this.table.columnManager.getColumnsByFieldRoot(attrname);
279
+
280
+ columns.forEach((column) => {
281
+ let cell = this.getCell(column.getField());
282
+
283
+ if(cell){
284
+ let value = column.getFieldValue(newRowData);
285
+ if(cell.getValue() !== value){
286
+ cellsToUpdate.push([cell, value]);
287
+ }
288
+ }
289
+ });
290
+ }
291
+
292
+ //set data
293
+ for (let attrname in newRowData) {
294
+ this.data[attrname] = newRowData[attrname];
295
+ }
296
+
297
+ this.dispatch("row-data-save-after", this);
298
+
299
+ //update affected cells only
300
+ cellsToUpdate.forEach(([cell, value]) => {
301
+ cell.setValueProcessData(value);
302
+
303
+ if(visible){
304
+ cell.cellRendered();
305
+ }
306
+ });
307
+
308
+ //Partial reinitialization if visible
309
+ if(visible){
310
+ this.normalizeHeight(true);
311
+
312
+ if(this.table.options.rowFormatter){
313
+ this.table.options.rowFormatter(this.getComponent());
314
+ }
315
+ }else{
316
+ this.initialized = false;
317
+ this.height = 0;
318
+ this.heightStyled = "";
319
+ }
320
+
321
+ this.dispatch("row-data-changed", this, visible, updatedData);
322
+
323
+ //this.reinitialize();
324
+
325
+ this.dispatchExternal("rowUpdated", this.getComponent());
326
+
327
+ if(this.subscribedExternal("dataChanged")){
328
+ this.dispatchExternal("dataChanged", this.table.rowManager.getData());
329
+ }
330
+
331
+ resolve();
332
+ });
333
+ }
334
+
335
+ getData(transform){
336
+ if(transform){
337
+ return this.chain("row-data-retrieve", [this, transform], null, this.data);
338
+ }
339
+
340
+ return this.data;
341
+ }
342
+
343
+ getCell(column){
344
+ var match = false;
345
+
346
+ column = this.table.columnManager.findColumn(column);
347
+
348
+ if(!this.initialized && this.cells.length === 0){
349
+ this.generateCells();
350
+ }
351
+
352
+ match = this.cells.find(function(cell){
353
+ return cell.column === column;
354
+ });
355
+
356
+ return match;
357
+ }
358
+
359
+ getCellIndex(findCell){
360
+ return this.cells.findIndex(function(cell){
361
+ return cell === findCell;
362
+ });
363
+ }
364
+
365
+ findCell(subject){
366
+ return this.cells.find((cell) => {
367
+ return cell.element === subject;
368
+ });
369
+ }
370
+
371
+ getCells(){
372
+ if(!this.initialized && this.cells.length === 0){
373
+ this.generateCells();
374
+ }
375
+
376
+ return this.cells;
377
+ }
378
+
379
+ nextRow(){
380
+ var row = this.table.rowManager.nextDisplayRow(this, true);
381
+ return row || false;
382
+ }
383
+
384
+ prevRow(){
385
+ var row = this.table.rowManager.prevDisplayRow(this, true);
386
+ return row || false;
387
+ }
388
+
389
+ moveToRow(to, before){
390
+ var toRow = this.table.rowManager.findRow(to);
391
+
392
+ if(toRow){
393
+ this.table.rowManager.moveRowActual(this, toRow, !before);
394
+ this.table.rowManager.refreshActiveData("display", false, true);
395
+ }else{
396
+ console.warn("Move Error - No matching row found:", to);
397
+ }
398
+ }
399
+
400
+ ///////////////////// Actions /////////////////////
401
+ delete(){
402
+ this.dispatch("row-delete", this);
403
+
404
+ this.deleteActual();
405
+
406
+ return Promise.resolve();
407
+ }
408
+
409
+ deleteActual(blockRedraw){
410
+ this.detachModules();
411
+
412
+ this.table.rowManager.deleteRow(this, blockRedraw);
413
+
414
+ this.deleteCells();
415
+
416
+ this.initialized = false;
417
+ this.heightInitialized = false;
418
+ this.element = false;
419
+
420
+ this.dispatch("row-deleted", this);
421
+ }
422
+
423
+ detachModules(){
424
+ this.dispatch("row-deleting", this);
425
+ }
426
+
427
+ deleteCells(){
428
+ var cellCount = this.cells.length;
429
+
430
+ for(let i = 0; i < cellCount; i++){
431
+ this.cells[0].delete();
432
+ }
433
+ }
434
+
435
+ wipe(){
436
+ this.detachModules();
437
+ this.deleteCells();
438
+
439
+ if(this.element){
440
+ while(this.element.firstChild) this.element.removeChild(this.element.firstChild);
441
+
442
+ if(this.element.parentNode){
443
+ this.element.parentNode.removeChild(this.element);
444
+ }
445
+ }
446
+
447
+ this.element = false;
448
+ this.modules = {};
449
+ }
450
+
451
+ isDisplayed(){
452
+ return this.table.rowManager.getDisplayRows().includes(this);
453
+ }
454
+
455
+ getPosition(){
456
+ return this.isDisplayed() ? this.position : false;
457
+ }
458
+
459
+ setPosition(position){
460
+ if(position != this.position){
461
+ this.position = position;
462
+
463
+ this.positionWatchers.forEach((callback) => {
464
+ callback(this.position);
465
+ });
466
+ }
467
+ }
468
+
469
+ watchPosition(callback){
470
+ this.positionWatchers.push(callback);
471
+
472
+ callback(this.position);
473
+ }
474
+
475
+ getGroup(){
476
+ return this.modules.group || false;
477
+ }
478
+
479
+ //////////////// Object Generation /////////////////
480
+ getComponent(){
481
+ if(!this.component){
482
+ this.component = new RowComponent(this);
483
+ }
484
+
485
+ return this.component;
486
+ }
487
+ }
@@ -0,0 +1,94 @@
1
+ //public row object
2
+ export default class RowComponent {
3
+
4
+ constructor (row){
5
+ this._row = row;
6
+
7
+ return new Proxy(this, {
8
+ get: function(target, name, receiver) {
9
+ if (typeof target[name] !== "undefined") {
10
+ return target[name];
11
+ }else{
12
+ return target._row.table.componentFunctionBinder.handle("row", target._row, name);
13
+ }
14
+ }
15
+ });
16
+ }
17
+
18
+ getData(transform){
19
+ return this._row.getData(transform);
20
+ }
21
+
22
+ getElement(){
23
+ return this._row.getElement();
24
+ }
25
+
26
+ getCells(){
27
+ var cells = [];
28
+
29
+ this._row.getCells().forEach(function(cell){
30
+ cells.push(cell.getComponent());
31
+ });
32
+
33
+ return cells;
34
+ }
35
+
36
+ getCell(column){
37
+ var cell = this._row.getCell(column);
38
+ return cell ? cell.getComponent() : false;
39
+ }
40
+
41
+ getIndex(){
42
+ return this._row.getData("data")[this._row.table.options.index];
43
+ }
44
+
45
+ getPosition(){
46
+ return this._row.getPosition();
47
+ }
48
+
49
+ watchPosition(callback){
50
+ return this._row.watchPosition(callback);
51
+ }
52
+
53
+ delete(){
54
+ return this._row.delete();
55
+ }
56
+
57
+ scrollTo(position, ifVisible){
58
+ return this._row.table.rowManager.scrollToRow(this._row, position, ifVisible);
59
+ }
60
+
61
+ move(to, after){
62
+ this._row.moveToRow(to, after);
63
+ }
64
+
65
+ update(data){
66
+ return this._row.updateData(data);
67
+ }
68
+
69
+ normalizeHeight(){
70
+ this._row.normalizeHeight(true);
71
+ }
72
+
73
+ _getSelf(){
74
+ return this._row;
75
+ }
76
+
77
+ reformat(){
78
+ return this._row.reinitialize();
79
+ }
80
+
81
+ getTable(){
82
+ return this._row.table;
83
+ }
84
+
85
+ getNextRow(){
86
+ var row = this._row.nextRow();
87
+ return row ? row.getComponent() : row;
88
+ }
89
+
90
+ getPrevRow(){
91
+ var row = this._row.prevRow();
92
+ return row ? row.getComponent() : row;
93
+ }
94
+ }
@@ -0,0 +1,66 @@
1
+ import CoreFeature from '../CoreFeature.js';
2
+
3
+ export default class Alert extends CoreFeature{
4
+ constructor(table){
5
+ super(table);
6
+
7
+ this.element = this._createAlertElement();
8
+ this.msgElement = this._createMsgElement();
9
+ this.type = null;
10
+
11
+ this.element.appendChild(this.msgElement);
12
+ }
13
+
14
+ _createAlertElement(){
15
+ var el = document.createElement("div");
16
+ el.classList.add("tabulator-alert");
17
+ return el;
18
+ }
19
+
20
+ _createMsgElement(){
21
+ var el = document.createElement("div");
22
+ el.classList.add("tabulator-alert-msg");
23
+ el.setAttribute("role", "alert");
24
+ return el;
25
+ }
26
+
27
+ _typeClass(){
28
+ return "tabulator-alert-state-" + this.type;
29
+ }
30
+
31
+ alert(content, type = "msg"){
32
+ if(content){
33
+ this.clear();
34
+
35
+ this.dispatch("alert-show", type);
36
+
37
+ this.type = type;
38
+
39
+ while(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);
40
+
41
+ this.msgElement.classList.add(this._typeClass());
42
+
43
+ if(typeof content === "function"){
44
+ content = content();
45
+ }
46
+
47
+ if(content instanceof HTMLElement){
48
+ this.msgElement.appendChild(content);
49
+ }else{
50
+ this.msgElement.innerHTML = content;
51
+ }
52
+
53
+ this.table.element.appendChild(this.element);
54
+ }
55
+ }
56
+
57
+ clear(){
58
+ this.dispatch("alert-hide", this.type);
59
+
60
+ if(this.element.parentNode){
61
+ this.element.parentNode.removeChild(this.element);
62
+ }
63
+
64
+ this.msgElement.classList.remove(this._typeClass());
65
+ }
66
+ }
@@ -0,0 +1,32 @@
1
+ export default class ComponentFunctionBinder{
2
+
3
+ constructor(table){
4
+ this.table = table;
5
+
6
+ this.bindings = {};
7
+ }
8
+
9
+ bind(type, funcName, handler){
10
+ if(!this.bindings[type]){
11
+ this.bindings[type] = {};
12
+ }
13
+
14
+ if(this.bindings[type][funcName]){
15
+ console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, handler);
16
+ }else{
17
+ this.bindings[type][funcName] = handler;
18
+ }
19
+ }
20
+
21
+ handle(type, component, name){
22
+ if(this.bindings[type] && this.bindings[type][name] && typeof this.bindings[type][name].bind === 'function'){
23
+ return this.bindings[type][name].bind(null, component);
24
+ }else{
25
+ if(name !== "then" && typeof name === "string" && !name.startsWith("_")){
26
+ if(this.table.options.debugInvalidComponentFuncs){
27
+ console.error("The " + type + " component does not have a " + name + " function, have you checked that you have the correct Tabulator module installed?");
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }