tabulator-tables 5.4.3 → 5.5.0

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 +80 -53
  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 +89 -58
  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 +106 -73
  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 +110 -75
  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 +95 -62
  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 +93 -63
  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 +90 -59
  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 +96 -62
  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 +233 -182
  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 +80 -53
  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 +88 -57
  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 +26054 -25713
  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 +26131 -25790
  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 +745 -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 +1128 -1101
  79. package/src/js/core/Tabulator.js +895 -892
  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 +78 -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 +24 -19
  91. package/src/js/core/rendering/renderers/BasicVertical.js +83 -79
  92. package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +582 -577
  93. package/src/js/core/rendering/renderers/VirtualDomVertical.js +634 -580
  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 +92 -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 +102 -99
  130. package/src/js/modules/Download/defaults/downloaders.js +14 -14
  131. package/src/js/modules/Edit/Edit.js +734 -736
  132. package/src/js/modules/Edit/List.js +1048 -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 +626 -623
  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 +903 -892
  152. package/src/js/modules/Filter/defaults/filters.js +107 -107
  153. package/src/js/modules/Format/Format.js +215 -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 +43 -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 -598
  178. package/src/js/modules/GroupRows/GroupComponent.js +70 -66
  179. package/src/js/modules/GroupRows/GroupRows.js +639 -639
  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 +337 -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 -185
  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 +472 -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 -137
  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 +348 -345
  219. package/src/js/modules/SelectRow/SelectRow.js +474 -444
  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 +1496 -1467
  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 +288 -284
  238. package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +552 -544
  239. package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +584 -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 +258 -252
  244. package/src/scss/themes/bulma/variables.scss +197 -197
  245. package/src/scss/themes/materialize/tabulator_materialize.scss +269 -265
  246. package/src/scss/themes/materialize/variables.scss +70 -70
  247. package/src/scss/themes/semanticui/tabulator_semanticui.scss +586 -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 +162 -158
  251. package/src/scss/themes/tabulator_modern.scss +239 -231
  252. package/src/scss/themes/tabulator_simple.scss +102 -102
  253. package/src/scss/themes/tabulator_site.scss +193 -189
@@ -1,94 +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(){
58
- return this._row.table.rowManager.scrollToRow(this._row);
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
- }
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
94
  }
@@ -1,62 +1,62 @@
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.type = type;
36
-
37
- while(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);
38
-
39
- this.msgElement.classList.add(this._typeClass());
40
-
41
- if(typeof content === "function"){
42
- content = content();
43
- }
44
-
45
- if(content instanceof HTMLElement){
46
- this.msgElement.appendChild(content);
47
- }else{
48
- this.msgElement.innerHTML = content;
49
- }
50
-
51
- this.table.element.appendChild(this.element);
52
- }
53
- }
54
-
55
- clear(){
56
- if(this.element.parentNode){
57
- this.element.parentNode.removeChild(this.element);
58
- }
59
-
60
- this.msgElement.classList.remove(this._typeClass());
61
- }
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.type = type;
36
+
37
+ while(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);
38
+
39
+ this.msgElement.classList.add(this._typeClass());
40
+
41
+ if(typeof content === "function"){
42
+ content = content();
43
+ }
44
+
45
+ if(content instanceof HTMLElement){
46
+ this.msgElement.appendChild(content);
47
+ }else{
48
+ this.msgElement.innerHTML = content;
49
+ }
50
+
51
+ this.table.element.appendChild(this.element);
52
+ }
53
+ }
54
+
55
+ clear(){
56
+ if(this.element.parentNode){
57
+ this.element.parentNode.removeChild(this.element);
58
+ }
59
+
60
+ this.msgElement.classList.remove(this._typeClass());
61
+ }
62
62
  }
@@ -1,32 +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
- }
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
+ }
@@ -1,120 +1,120 @@
1
- import CoreFeature from '../CoreFeature.js';
2
-
3
- export default class DataLoader extends CoreFeature{
4
- constructor(table){
5
- super(table);
6
-
7
- this.requestOrder = 0; //prevent requests coming out of sequence if overridden by another load request
8
- this.loading = false;
9
- }
10
-
11
- initialize(){}
12
-
13
- load(data, params, config, replace, silent, columnsChanged){
14
- var requestNo = ++this.requestOrder;
15
-
16
- this.dispatchExternal("dataLoading", data);
17
-
18
- //parse json data to array
19
- if (data && (data.indexOf("{") == 0 || data.indexOf("[") == 0)){
20
- data = JSON.parse(data);
21
- }
22
-
23
- if(this.confirm("data-loading", [data, params, config, silent])){
24
- this.loading = true;
25
-
26
- if(!silent){
27
- this.alertLoader();
28
- }
29
-
30
- //get params for request
31
- params = this.chain("data-params", [data, config, silent], params || {}, params || {});
32
-
33
- params = this.mapParams(params, this.table.options.dataSendParams);
34
-
35
- var result = this.chain("data-load", [data, params, config, silent], false, Promise.resolve([]));
36
-
37
- return result.then((response) => {
38
- if(!Array.isArray(response) && typeof response == "object"){
39
- response = this.mapParams(response, this.objectInvert(this.table.options.dataReceiveParams));
40
- }
41
-
42
- var rowData = this.chain("data-loaded", response, null, response);
43
-
44
- if(requestNo == this.requestOrder){
45
- this.clearAlert();
46
-
47
- if(rowData !== false){
48
- this.dispatchExternal("dataLoaded", rowData);
49
- this.table.rowManager.setData(rowData, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);
50
- }
51
- }else{
52
- console.warn("Data Load Response Blocked - An active data load request was blocked by an attempt to change table data while the request was being made");
53
- }
54
- }).catch((error) => {
55
- console.error("Data Load Error: ", error);
56
- this.dispatchExternal("dataLoadError", error);
57
-
58
- if(!silent){
59
- this.alertError();
60
- }
61
-
62
- setTimeout(() => {
63
- this.clearAlert();
64
- }, this.table.options.dataLoaderErrorTimeout);
65
- })
66
- .finally(() => {
67
- this.loading = false;
68
- });
69
- }else{
70
- this.dispatchExternal("dataLoaded", data);
71
-
72
- if(!data){
73
- data = [];
74
- }
75
-
76
- this.table.rowManager.setData(data, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);
77
- return Promise.resolve();
78
- }
79
- }
80
-
81
- mapParams(params, map){
82
- var output = {};
83
-
84
- for(let key in params){
85
- output[map.hasOwnProperty(key) ? map[key] : key] = params[key];
86
- }
87
-
88
- return output;
89
- }
90
-
91
- objectInvert(obj){
92
- var output = {};
93
-
94
- for(let key in obj){
95
- output[obj[key]] = key;
96
- }
97
-
98
- return output;
99
- }
100
-
101
- blockActiveLoad(){
102
- this.requestOrder++;
103
- }
104
-
105
- alertLoader(){
106
- var shouldLoad = typeof this.table.options.dataLoader === "function" ? this.table.options.dataLoader() : this.table.options.dataLoader;
107
-
108
- if(shouldLoad){
109
- this.table.alertManager.alert(this.table.options.dataLoaderLoading || this.langText("data|loading"));
110
- }
111
- }
112
-
113
- alertError(){
114
- this.table.alertManager.alert(this.table.options.dataLoaderError || this.langText("data|error"), "error");
115
- }
116
-
117
- clearAlert(){
118
- this.table.alertManager.clear();
119
- }
1
+ import CoreFeature from '../CoreFeature.js';
2
+
3
+ export default class DataLoader extends CoreFeature{
4
+ constructor(table){
5
+ super(table);
6
+
7
+ this.requestOrder = 0; //prevent requests coming out of sequence if overridden by another load request
8
+ this.loading = false;
9
+ }
10
+
11
+ initialize(){}
12
+
13
+ load(data, params, config, replace, silent, columnsChanged){
14
+ var requestNo = ++this.requestOrder;
15
+
16
+ this.dispatchExternal("dataLoading", data);
17
+
18
+ //parse json data to array
19
+ if (data && (data.indexOf("{") == 0 || data.indexOf("[") == 0)){
20
+ data = JSON.parse(data);
21
+ }
22
+
23
+ if(this.confirm("data-loading", [data, params, config, silent])){
24
+ this.loading = true;
25
+
26
+ if(!silent){
27
+ this.alertLoader();
28
+ }
29
+
30
+ //get params for request
31
+ params = this.chain("data-params", [data, config, silent], params || {}, params || {});
32
+
33
+ params = this.mapParams(params, this.table.options.dataSendParams);
34
+
35
+ var result = this.chain("data-load", [data, params, config, silent], false, Promise.resolve([]));
36
+
37
+ return result.then((response) => {
38
+ if(!Array.isArray(response) && typeof response == "object"){
39
+ response = this.mapParams(response, this.objectInvert(this.table.options.dataReceiveParams));
40
+ }
41
+
42
+ var rowData = this.chain("data-loaded", response, null, response);
43
+
44
+ if(requestNo == this.requestOrder){
45
+ this.clearAlert();
46
+
47
+ if(rowData !== false){
48
+ this.dispatchExternal("dataLoaded", rowData);
49
+ this.table.rowManager.setData(rowData, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);
50
+ }
51
+ }else{
52
+ console.warn("Data Load Response Blocked - An active data load request was blocked by an attempt to change table data while the request was being made");
53
+ }
54
+ }).catch((error) => {
55
+ console.error("Data Load Error: ", error);
56
+ this.dispatchExternal("dataLoadError", error);
57
+
58
+ if(!silent){
59
+ this.alertError();
60
+ }
61
+
62
+ setTimeout(() => {
63
+ this.clearAlert();
64
+ }, this.table.options.dataLoaderErrorTimeout);
65
+ })
66
+ .finally(() => {
67
+ this.loading = false;
68
+ });
69
+ }else{
70
+ this.dispatchExternal("dataLoaded", data);
71
+
72
+ if(!data){
73
+ data = [];
74
+ }
75
+
76
+ this.table.rowManager.setData(data, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);
77
+ return Promise.resolve();
78
+ }
79
+ }
80
+
81
+ mapParams(params, map){
82
+ var output = {};
83
+
84
+ for(let key in params){
85
+ output[map.hasOwnProperty(key) ? map[key] : key] = params[key];
86
+ }
87
+
88
+ return output;
89
+ }
90
+
91
+ objectInvert(obj){
92
+ var output = {};
93
+
94
+ for(let key in obj){
95
+ output[obj[key]] = key;
96
+ }
97
+
98
+ return output;
99
+ }
100
+
101
+ blockActiveLoad(){
102
+ this.requestOrder++;
103
+ }
104
+
105
+ alertLoader(){
106
+ var shouldLoad = typeof this.table.options.dataLoader === "function" ? this.table.options.dataLoader() : this.table.options.dataLoader;
107
+
108
+ if(shouldLoad){
109
+ this.table.alertManager.alert(this.table.options.dataLoaderLoading || this.langText("data|loading"));
110
+ }
111
+ }
112
+
113
+ alertError(){
114
+ this.table.alertManager.alert(this.table.options.dataLoaderError || this.langText("data|error"), "error");
115
+ }
116
+
117
+ clearAlert(){
118
+ this.table.alertManager.clear();
119
+ }
120
120
  }