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,366 @@
1
+ import CoreFeature from '../../core/CoreFeature.js';
2
+ import RangeComponent from "./RangeComponent";
3
+
4
+ export default class Range extends CoreFeature{
5
+ constructor(table, rangeManager, start, end) {
6
+ super(table);
7
+
8
+ this.rangeManager = rangeManager;
9
+ this.element = null;
10
+ this.initialized = false;
11
+ this.initializing = {
12
+ start:false,
13
+ end:false,
14
+ };
15
+ this.destroyed = false;
16
+
17
+ this.top = 0;
18
+ this.bottom = 0;
19
+ this.left = 0;
20
+ this.right = 0;
21
+
22
+ this.table = table;
23
+ this.start = {row:undefined, col:undefined};
24
+ this.end = {row:undefined, col:undefined};
25
+
26
+ if(this.rangeManager.rowHeader){
27
+ this.left = 1;
28
+ this.right = 1;
29
+ this.start.col = 1;
30
+ this.end.col = 1;
31
+ }
32
+
33
+ this.initElement();
34
+
35
+ setTimeout(() => {
36
+ this.initBounds(start, end);
37
+ });
38
+ }
39
+
40
+ initElement(){
41
+ this.element = document.createElement("div");
42
+ this.element.classList.add("tabulator-range");
43
+ }
44
+
45
+ initBounds(start, end){
46
+ this._updateMinMax();
47
+
48
+ if(start){
49
+ this.setBounds(start, end || start);
50
+ }
51
+ }
52
+
53
+ ///////////////////////////////////
54
+ /////// Boundary Setup ///////
55
+ ///////////////////////////////////
56
+
57
+ setStart(row, col) {
58
+ if(this.start.row !== row || this.start.col !== col){
59
+ this.start.row = row;
60
+ this.start.col = col;
61
+
62
+ this.initializing.start = true;
63
+ this._updateMinMax();
64
+ }
65
+ }
66
+
67
+ setEnd(row, col) {
68
+ if(this.end.row !== row || this.end.col !== col){
69
+ this.end.row = row;
70
+ this.end.col = col;
71
+
72
+ this.initializing.end = true;
73
+ this._updateMinMax();
74
+ }
75
+ }
76
+
77
+ setBounds(start, end, visibleRows){
78
+ if(start){
79
+ this.setStartBound(start);
80
+ }
81
+
82
+ this.setEndBound(end || start);
83
+ this.rangeManager.layoutElement(visibleRows);
84
+ }
85
+
86
+ setStartBound(element){
87
+ var row, col;
88
+
89
+ if (element.type === "column") {
90
+ if(this.rangeManager.columnSelection){
91
+ this.setStart(0, element.getPosition() - 1);
92
+ }
93
+ }else{
94
+ row = element.row.position - 1;
95
+ col = element.column.getPosition() - 1;
96
+
97
+ if (element.column === this.rangeManager.rowHeader) {
98
+ this.setStart(row, 1);
99
+ } else {
100
+ this.setStart(row, col);
101
+ }
102
+ }
103
+ }
104
+
105
+ setEndBound(element){
106
+ var rowsCount = this._getTableRows().length,
107
+ row, col, isRowHeader;
108
+
109
+ if (element.type === "column") {
110
+ if(this.rangeManager.columnSelection){
111
+ if (this.rangeManager.selecting === "column") {
112
+ this.setEnd(rowsCount - 1, element.getPosition() - 1);
113
+ } else if (this.rangeManager.selecting === "cell") {
114
+ this.setEnd(0, element.getPosition() - 1);
115
+ }
116
+ }
117
+ }else{
118
+ row = element.row.position - 1;
119
+ col = element.column.getPosition() - 1;
120
+ isRowHeader = element.column === this.rangeManager.rowHeader;
121
+
122
+ if (this.rangeManager.selecting === "row") {
123
+ this.setEnd(row, this._getTableColumns().length - 1);
124
+ } else if (this.rangeManager.selecting !== "row" && isRowHeader) {
125
+ this.setEnd(row, 0);
126
+ } else if (this.rangeManager.selecting === "column") {
127
+ this.setEnd(rowsCount - 1, col);
128
+ } else {
129
+ this.setEnd(row, col);
130
+ }
131
+ }
132
+ }
133
+
134
+ _updateMinMax() {
135
+ this.top = Math.min(this.start.row, this.end.row);
136
+ this.bottom = Math.max(this.start.row, this.end.row);
137
+ this.left = Math.min(this.start.col, this.end.col);
138
+ this.right = Math.max(this.start.col, this.end.col);
139
+
140
+ if(this.initialized){
141
+ this.dispatchExternal("rangeChanged", this.getComponent());
142
+ }else{
143
+ if(this.initializing.start && this.initializing.end){
144
+ this.initialized = true;
145
+ this.dispatchExternal("rangeAdded", this.getComponent());
146
+ }
147
+ }
148
+ }
149
+
150
+ _getTableColumns() {
151
+ return this.table.columnManager.getVisibleColumnsByIndex();
152
+ }
153
+
154
+ _getTableRows() {
155
+ return this.table.rowManager.getDisplayRows().filter(row=> row.type === "row");
156
+ }
157
+
158
+ ///////////////////////////////////
159
+ /////// Rendering ///////
160
+ ///////////////////////////////////
161
+
162
+ layout() {
163
+ var _vDomTop = this.table.rowManager.renderer.vDomTop,
164
+ _vDomBottom = this.table.rowManager.renderer.vDomBottom,
165
+ _vDomLeft = this.table.columnManager.renderer.leftCol,
166
+ _vDomRight = this.table.columnManager.renderer.rightCol,
167
+ top, bottom, left, right, topLeftCell, bottomRightCell, topLeftCellEl, bottomRightCellEl, topLeftRowEl, bottomRightRowEl;
168
+
169
+ if(this.table.options.renderHorizontal === "virtual" && this.rangeManager.rowHeader) {
170
+ _vDomRight += 1;
171
+ }
172
+
173
+ if (_vDomTop == null) {
174
+ _vDomTop = 0;
175
+ }
176
+
177
+ if (_vDomBottom == null) {
178
+ _vDomBottom = Infinity;
179
+ }
180
+
181
+ if (_vDomLeft == null) {
182
+ _vDomLeft = 0;
183
+ }
184
+
185
+ if (_vDomRight == null) {
186
+ _vDomRight = Infinity;
187
+ }
188
+
189
+ if (this.overlaps(_vDomLeft, _vDomTop, _vDomRight, _vDomBottom)) {
190
+ top = Math.max(this.top, _vDomTop);
191
+ bottom = Math.min(this.bottom, _vDomBottom);
192
+ left = Math.max(this.left, _vDomLeft);
193
+ right = Math.min(this.right, _vDomRight);
194
+
195
+ topLeftCell = this.rangeManager.getCell(top, left);
196
+ bottomRightCell = this.rangeManager.getCell(bottom, right);
197
+ topLeftCellEl = topLeftCell.getElement();
198
+ bottomRightCellEl = bottomRightCell.getElement();
199
+ topLeftRowEl = topLeftCell.row.getElement();
200
+ bottomRightRowEl = bottomRightCell.row.getElement();
201
+
202
+ this.element.classList.add("tabulator-range-active");
203
+ // this.element.classList.toggle("tabulator-range-active", this === this.rangeManager.activeRange);
204
+
205
+ if(this.table.rtl){
206
+ this.element.style.right = topLeftRowEl.offsetWidth - topLeftCellEl.offsetLeft - topLeftCellEl.offsetWidth + "px";
207
+ this.element.style.width = topLeftCellEl.offsetLeft + topLeftCellEl.offsetWidth - bottomRightCellEl.offsetLeft + "px";
208
+ }else{
209
+ this.element.style.left = topLeftRowEl.offsetLeft + topLeftCellEl.offsetLeft + "px";
210
+ this.element.style.width = bottomRightCellEl.offsetLeft + bottomRightCellEl.offsetWidth - topLeftCellEl.offsetLeft + "px";
211
+ }
212
+
213
+ this.element.style.top = topLeftRowEl.offsetTop + "px";
214
+ this.element.style.height = bottomRightRowEl.offsetTop + bottomRightRowEl.offsetHeight - topLeftRowEl.offsetTop + "px";
215
+ }
216
+ }
217
+
218
+ atTopLeft(cell) {
219
+ return cell.row.position - 1 === this.top && cell.column.getPosition() - 1 === this.left;
220
+ }
221
+
222
+ atBottomRight(cell) {
223
+ return cell.row.position - 1 === this.bottom && cell.column.getPosition() - 1 === this.right;
224
+ }
225
+
226
+ occupies(cell) {
227
+ return this.occupiesRow(cell.row) && this.occupiesColumn(cell.column);
228
+ }
229
+
230
+ occupiesRow(row) {
231
+ return this.top <= row.position - 1 && row.position - 1 <= this.bottom;
232
+ }
233
+
234
+ occupiesColumn(col) {
235
+ return this.left <= col.getPosition() - 1 && col.getPosition() - 1 <= this.right;
236
+ }
237
+
238
+ overlaps(left, top, right, bottom) {
239
+ if ((this.left > right || left > this.right) || (this.top > bottom || top > this.bottom)){
240
+ return false;
241
+ }
242
+
243
+ return true;
244
+ }
245
+
246
+ getData() {
247
+ var data = [],
248
+ rows = this.getRows(),
249
+ columns = this.getColumns();
250
+
251
+ rows.forEach((row) => {
252
+ var rowData = row.getData(),
253
+ result = {};
254
+
255
+ columns.forEach((column) => {
256
+ result[column.field] = rowData[column.field];
257
+ });
258
+
259
+ data.push(result);
260
+ });
261
+
262
+ return data;
263
+ }
264
+
265
+ getCells(structured, component) {
266
+ var cells = [],
267
+ rows = this.getRows(),
268
+ columns = this.getColumns();
269
+
270
+ if (structured) {
271
+ cells = rows.map((row) => {
272
+ var arr = [];
273
+
274
+ row.getCells().forEach((cell) => {
275
+ if (columns.includes(cell.column)) {
276
+ arr.push(component ? cell.getComponent() : cell);
277
+ }
278
+ });
279
+
280
+ return arr;
281
+ });
282
+ } else {
283
+ rows.forEach((row) => {
284
+ row.getCells().forEach((cell) => {
285
+ if (columns.includes(cell.column)) {
286
+ cells.push(component ? cell.getComponent() : cell);
287
+ }
288
+ });
289
+ });
290
+ }
291
+
292
+ return cells;
293
+ }
294
+
295
+ getStructuredCells() {
296
+ return this.getCells(true, true);
297
+ }
298
+
299
+ getRows() {
300
+ return this._getTableRows().slice(this.top, this.bottom + 1);
301
+ }
302
+
303
+ getColumns() {
304
+ return this._getTableColumns().slice(this.left, this.right + 1);
305
+ }
306
+
307
+ clearValues(){
308
+ var cells = this.getCells();
309
+ var clearValue = this.table.options.selectableRangeClearCellsValue;
310
+
311
+ this.table.blockRedraw();
312
+
313
+ cells.forEach((cell) => {
314
+ cell.setValue(clearValue);
315
+ });
316
+
317
+ this.table.restoreRedraw();
318
+
319
+ }
320
+
321
+ getBounds(component){
322
+ var cells = this.getCells(false, component),
323
+ output = {
324
+ start:null,
325
+ end:null,
326
+ };
327
+
328
+ if(cells.length){
329
+ output.start = cells[0];
330
+ output.end = cells[cells.length - 1];
331
+ }else{
332
+ console.warn("No bounds defined on range");
333
+ }
334
+
335
+ return output;
336
+ }
337
+
338
+ getComponent() {
339
+ if (!this.component) {
340
+ this.component = new RangeComponent(this);
341
+ }
342
+ return this.component;
343
+ }
344
+
345
+ destroy(notify) {
346
+ this.destroyed = true;
347
+
348
+ this.element.remove();
349
+
350
+ if(notify){
351
+ this.rangeManager.rangeRemoved(this);
352
+ }
353
+
354
+ if(this.initialized){
355
+ this.dispatchExternal("rangeRemoved", this.getComponent());
356
+ }
357
+ }
358
+
359
+ destroyedGuard(func){
360
+ if(this.destroyed){
361
+ console.warn("You cannot call the " + func + " function on a destroyed range");
362
+ }
363
+
364
+ return !this.destroyed;
365
+ }
366
+ }
@@ -0,0 +1,91 @@
1
+ export default class RangeComponent {
2
+ constructor(range) {
3
+ this._range = range;
4
+
5
+ return new Proxy(this, {
6
+ get: function (target, name, receiver) {
7
+ if (typeof target[name] !== "undefined") {
8
+ return target[name];
9
+ } else {
10
+ return target._range.table.componentFunctionBinder.handle("range", target._range, name);
11
+ }
12
+ },
13
+ });
14
+ }
15
+
16
+ getElement() {
17
+ return this._range.element;
18
+ }
19
+
20
+ getData() {
21
+ return this._range.getData();
22
+ }
23
+
24
+ getCells() {
25
+ return this._range.getCells(true, true);
26
+ }
27
+
28
+ getStructuredCells() {
29
+ return this._range.getStructuredCells();
30
+ }
31
+
32
+ getRows() {
33
+ return this._range.getRows().map((row) => row.getComponent());
34
+ }
35
+
36
+ getColumns() {
37
+ return this._range.getColumns().map((column) => column.getComponent());
38
+ }
39
+
40
+ getBounds() {
41
+ return this._range.getBounds();
42
+ }
43
+
44
+ getTopEdge() {
45
+ return this._range.top;
46
+ }
47
+
48
+ getBottomEdge() {
49
+ return this._range.bottom;
50
+ }
51
+
52
+ getLeftEdge() {
53
+ return this._range.left;
54
+ }
55
+
56
+ getRightEdge() {
57
+ return this._range.right;
58
+ }
59
+
60
+ setBounds(start, end){
61
+ if(this._range.destroyedGuard("setBounds")){
62
+ this._range.setBounds(start ? start._cell : start, end ? end._cell : end);
63
+ }
64
+ }
65
+
66
+ setStartBound(start){
67
+ if(this._range.destroyedGuard("setStartBound")){
68
+ this._range.setEndBound(start ? start._cell : start);
69
+ this._range.rangeManager.layoutElement();
70
+ }
71
+ }
72
+
73
+ setEndBound(end){
74
+ if(this._range.destroyedGuard("setEndBound")){
75
+ this._range.setEndBound(end ? end._cell : end);
76
+ this._range.rangeManager.layoutElement();
77
+ }
78
+ }
79
+
80
+ clearValues(){
81
+ if(this._range.destroyedGuard("clearValues")){
82
+ this._range.clearValues();
83
+ }
84
+ }
85
+
86
+ remove(){
87
+ if(this._range.destroyedGuard("remove")){
88
+ this._range.destroy(true);
89
+ }
90
+ }
91
+ }