tabulator-tables 5.1.8 → 5.2.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.
- package/bower.json +1 -1
- package/dist/css/tabulator.css +59 -51
- package/dist/css/tabulator.css.map +1 -1
- package/dist/css/tabulator.min.css +1 -1
- package/dist/css/tabulator.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.css +59 -51
- package/dist/css/tabulator_bootstrap3.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.min.css +1 -1
- package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.css +59 -51
- package/dist/css/tabulator_bootstrap4.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.min.css +1 -1
- package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.css +1575 -0
- package/dist/css/tabulator_bootstrap5.css.map +1 -0
- package/dist/css/tabulator_bootstrap5.min.css +2 -0
- package/dist/css/tabulator_bootstrap5.min.css.map +1 -0
- package/dist/css/tabulator_bulma.css +59 -51
- package/dist/css/tabulator_bulma.css.map +1 -1
- package/dist/css/tabulator_bulma.min.css +1 -1
- package/dist/css/tabulator_bulma.min.css.map +1 -1
- package/dist/css/tabulator_materialize.css +59 -51
- package/dist/css/tabulator_materialize.css.map +1 -1
- package/dist/css/tabulator_materialize.min.css +1 -1
- package/dist/css/tabulator_materialize.min.css.map +1 -1
- package/dist/css/tabulator_midnight.css +59 -51
- package/dist/css/tabulator_midnight.css.map +1 -1
- package/dist/css/tabulator_midnight.min.css +1 -1
- package/dist/css/tabulator_midnight.min.css.map +1 -1
- package/dist/css/tabulator_modern.css +59 -51
- package/dist/css/tabulator_modern.css.map +1 -1
- package/dist/css/tabulator_modern.min.css +1 -1
- package/dist/css/tabulator_modern.min.css.map +1 -1
- package/dist/css/tabulator_semanticui.css +59 -51
- package/dist/css/tabulator_semanticui.css.map +1 -1
- package/dist/css/tabulator_semanticui.min.css +1 -1
- package/dist/css/tabulator_semanticui.min.css.map +1 -1
- package/dist/css/tabulator_simple.css +59 -51
- package/dist/css/tabulator_simple.css.map +1 -1
- package/dist/css/tabulator_simple.min.css +1 -1
- package/dist/css/tabulator_simple.min.css.map +1 -1
- package/dist/css/tabulator_site.css +59 -51
- package/dist/css/tabulator_site.css.map +1 -1
- package/dist/css/tabulator_site.min.css +1 -1
- package/dist/css/tabulator_site.min.css.map +1 -1
- package/dist/js/tabulator.js +2539 -1658
- package/dist/js/tabulator.js.map +1 -1
- package/dist/js/tabulator.min.js +2 -2
- package/dist/js/tabulator.min.js.map +1 -1
- package/dist/js/tabulator_esm.js +2742 -2066
- package/dist/js/tabulator_esm.js.map +1 -1
- package/dist/js/tabulator_esm.min.js +2 -2
- package/dist/js/tabulator_esm.min.js.map +1 -1
- package/package.json +1 -1
- package/src/js/core/FooterManager.js +6 -13
- package/src/js/core/Module.js +44 -2
- package/src/js/core/Tabulator.js +341 -289
- package/src/js/core/cell/Cell.js +9 -38
- package/src/js/core/column/Column.js +8 -44
- package/src/js/core/column/defaults/options.js +0 -2
- package/src/js/core/defaults/options.js +5 -2
- package/src/js/core/modules/optional.js +2 -0
- package/src/js/core/row/Row.js +127 -118
- package/src/js/core/tools/Alert.js +63 -0
- package/src/js/core/tools/DataLoader.js +12 -84
- package/src/js/core/tools/InteractionMonitor.js +1 -1
- package/src/js/core/tools/ModuleBinder.js +30 -23
- package/src/js/core/tools/Popup.js +251 -0
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +2 -2
- package/src/js/modules/Edit/Edit.js +5 -25
- package/src/js/modules/Edit/List.js +997 -0
- package/src/js/modules/Edit/defaults/editors/autocomplete.js +6 -446
- package/src/js/modules/Edit/defaults/editors/input.js +4 -0
- package/src/js/modules/Edit/defaults/editors/list.js +7 -0
- package/src/js/modules/Edit/defaults/editors/number.js +4 -0
- package/src/js/modules/Edit/defaults/editors/select.js +5 -585
- package/src/js/modules/Edit/defaults/editors/textarea.js +4 -0
- package/src/js/modules/Edit/defaults/editors/tickCross.js +17 -5
- package/src/js/modules/Edit/defaults/editors.js +2 -0
- package/src/js/modules/Filter/Filter.js +7 -4
- package/src/js/modules/Format/defaults/formatters/datetime.js +9 -1
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +10 -3
- package/src/js/modules/Format/defaults/formatters/link.js +12 -1
- package/src/js/modules/Format/defaults/formatters/money.js +5 -3
- package/src/js/modules/Format/defaults/formatters/tickCross.js +2 -1
- package/src/js/modules/FrozenColumns/FrozenColumns.js +30 -8
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +5 -1
- package/src/js/modules/Menu/Menu.js +58 -158
- package/src/js/modules/Mutator/Mutator.js +20 -0
- package/src/js/modules/Page/Page.js +7 -3
- package/src/js/modules/Persistence/Persistence.js +1 -1
- package/src/js/modules/Popup/Popup.js +194 -0
- package/src/js/modules/ResizeColumns/ResizeColumns.js +138 -81
- package/src/js/modules/Sort/defaults/sorters/datetime.js +15 -2
- package/src/js/modules/Tooltip/Tooltip.js +132 -0
- package/src/js/modules/Validate/Validate.js +107 -71
- package/src/scss/tabulator.scss +349 -349
- package/src/scss/themes/bootstrap/functions5.scss +302 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +546 -0
- package/src/scss/themes/bootstrap/variables5.scss +1641 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import Module from '../../core/Module.js';
|
|
2
|
+
|
|
3
|
+
class Popup extends Module{
|
|
4
|
+
|
|
5
|
+
constructor(table){
|
|
6
|
+
super(table);
|
|
7
|
+
|
|
8
|
+
this.columnSubscribers = {};
|
|
9
|
+
|
|
10
|
+
this.registerTableOption("rowContextPopup", false);
|
|
11
|
+
this.registerTableOption("rowClickPopup", false);
|
|
12
|
+
this.registerTableOption("groupContextPopup", false);
|
|
13
|
+
this.registerTableOption("groupClickPopup", false);
|
|
14
|
+
|
|
15
|
+
this.registerColumnOption("headerContextPopup");
|
|
16
|
+
this.registerColumnOption("headerClickPopup");
|
|
17
|
+
this.registerColumnOption("headerPopup");
|
|
18
|
+
this.registerColumnOption("headerPopupIcon");
|
|
19
|
+
this.registerColumnOption("contextPopup");
|
|
20
|
+
this.registerColumnOption("clickPopup");
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
initialize(){
|
|
25
|
+
this.initializeRowWatchers();
|
|
26
|
+
this.initializeGroupWatchers();
|
|
27
|
+
|
|
28
|
+
this.subscribe("column-init", this.initializeColumn.bind(this));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
initializeRowWatchers(){
|
|
32
|
+
if(this.table.options.rowContextPopup){
|
|
33
|
+
this.subscribe("row-contextmenu", this.loadPopupEvent.bind(this, this.table.options.rowContextPopup));
|
|
34
|
+
this.table.on("rowTapHold", this.loadPopupEvent.bind(this, this.table.options.rowContextPopup));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if(this.table.options.rowClickPopup){
|
|
38
|
+
this.subscribe("row-click", this.loadPopupEvent.bind(this, this.table.options.rowClickPopup));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
initializeGroupWatchers(){
|
|
43
|
+
if(this.table.options.groupContextPopup){
|
|
44
|
+
this.subscribe("group-contextmenu", this.loadPopupEvent.bind(this, this.table.options.groupContextPopup));
|
|
45
|
+
this.table.on("groupTapHold", this.loadPopupEvent.bind(this, this.table.options.groupContextPopup));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if(this.table.options.groupClickPopup){
|
|
49
|
+
this.subscribe("group-click", this.loadPopupEvent.bind(this, this.table.options.groupClickPopup));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
initializeColumn(column){
|
|
54
|
+
var options = ["headerContextPopup", "headerClickPopup"],
|
|
55
|
+
def = column.definition;
|
|
56
|
+
|
|
57
|
+
//handle column events
|
|
58
|
+
if(def.headerContextPopup && !this.columnSubscribers.headerContextPopup){
|
|
59
|
+
this.columnSubscribers.headerContextPopup = this.loadPopupTableColumnEvent.bind(this, "headerContextPopup");
|
|
60
|
+
this.subscribe("column-contextmenu", this.columnSubscribers.headerContextPopup);
|
|
61
|
+
this.table.on("headerTapHold", this.loadPopupTableColumnEvent.bind(this, "headerContextPopup"))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if(def.headerClickPopup && !this.columnSubscribers.headerClickPopup){
|
|
65
|
+
this.columnSubscribers.headerClickPopup = this.loadPopupTableColumnEvent.bind(this, "headerClickPopup");
|
|
66
|
+
this.subscribe("column-click", this.columnSubscribers.headerClickPopup);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if(def.headerPopup){
|
|
70
|
+
this.initializeColumnHeaderPopup(column);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//handle cell events
|
|
74
|
+
if(def.contextPopup && !this.columnSubscribers.contextPopup){
|
|
75
|
+
this.columnSubscribers.contextPopup = this.loadPopupTableCellEvent.bind(this, "contextPopup");
|
|
76
|
+
this.subscribe("cell-contextmenu", this.columnSubscribers.contextPopup);
|
|
77
|
+
this.table.on("cellTapHold", this.loadPopupTableCellEvent.bind(this, "contextPopup"))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if(def.clickPopup && !this.columnSubscribers.clickPopup){
|
|
81
|
+
this.columnSubscribers.clickPopup = this.loadPopupTableCellEvent.bind(this, "clickPopup");
|
|
82
|
+
this.subscribe("cell-click", this.columnSubscribers.clickPopup);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
initializeColumnHeaderPopup(column){
|
|
87
|
+
var icon = column.definition.headerPopupIcon,
|
|
88
|
+
headerPopupEl;
|
|
89
|
+
|
|
90
|
+
headerPopupEl = document.createElement("span");
|
|
91
|
+
headerPopupEl.classList.add("tabulator-header-popup-button");
|
|
92
|
+
|
|
93
|
+
if(icon){
|
|
94
|
+
if(typeof icon === "function"){
|
|
95
|
+
icon = icon(column.getComponent());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if(icon instanceof HTMLElement){
|
|
99
|
+
headerPopupEl.appendChild(icon);
|
|
100
|
+
}else{
|
|
101
|
+
headerPopupEl.innerHTML = icon;
|
|
102
|
+
}
|
|
103
|
+
}else{
|
|
104
|
+
headerPopupEl.innerHTML = "⋮";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
headerPopupEl.addEventListener("click", (e) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
|
|
111
|
+
this.loadPopupEvent(column.definition.headerPopup, e, column);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
column.titleElement.insertBefore(headerPopupEl, column.titleElement.firstChild);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
loadPopupTableCellEvent(option, e, cell){
|
|
118
|
+
if(cell._cell){
|
|
119
|
+
cell = cell._cell;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if(cell.column.definition[option]){
|
|
123
|
+
this.loadPopupEvent(cell.column.definition[option], e, cell);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
loadPopupTableColumnEvent(option, e, column){
|
|
128
|
+
if(column._column){
|
|
129
|
+
column = column._column;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if(column.definition[option]){
|
|
133
|
+
this.loadPopupEvent(column.definition[option], e, column);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
loadPopupEvent(contents, e, component){
|
|
138
|
+
var renderedCallback;
|
|
139
|
+
|
|
140
|
+
function onRendered(callback){
|
|
141
|
+
renderedCallback = callback;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if(component._group){
|
|
145
|
+
component = component._group;
|
|
146
|
+
}else if(component._row){
|
|
147
|
+
component = component._row;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
contents = typeof contents == "function" ? contents.call(this.table, e, component.getComponent(), onRendered) : contents;
|
|
151
|
+
|
|
152
|
+
this.loadPopup(e, component, contents, renderedCallback);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
loadPopup(e, component, contents, renderedCallback){
|
|
156
|
+
var touch = !(e instanceof MouseEvent),
|
|
157
|
+
contentsEl, popup;
|
|
158
|
+
|
|
159
|
+
if(contents instanceof HTMLElement){
|
|
160
|
+
contentsEl = contents;
|
|
161
|
+
}else{
|
|
162
|
+
contentsEl = document.createElement("div");
|
|
163
|
+
contentsEl.innerHTML = contents;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
contentsEl.classList.add("tabulator-popup");
|
|
167
|
+
|
|
168
|
+
contentsEl.addEventListener("click", (e) =>{
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if(!touch){
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
popup = this.popup(contentsEl);
|
|
177
|
+
|
|
178
|
+
if(typeof renderedCallback === "function"){
|
|
179
|
+
popup.renderCallback(renderedCallback);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
popup.show(e).hideOnBlur(() => {
|
|
183
|
+
this.dispatchExternal("popupClosed", component.getComponent());
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
this.dispatchExternal("popupOpened", component.getComponent())
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
Popup.moduleName = "popup";
|
|
193
|
+
|
|
194
|
+
export default Popup;
|
|
@@ -8,126 +8,154 @@ class ResizeColumns extends Module{
|
|
|
8
8
|
this.startColumn = false;
|
|
9
9
|
this.startX = false;
|
|
10
10
|
this.startWidth = false;
|
|
11
|
+
this.latestX = false;
|
|
11
12
|
this.handle = null;
|
|
12
|
-
this.
|
|
13
|
+
this.initialNextColumn = null;
|
|
14
|
+
this.nextColumn = null;
|
|
13
15
|
|
|
16
|
+
this.initialized = false;
|
|
14
17
|
this.registerColumnOption("resizable", true);
|
|
18
|
+
this.registerTableOption("resizableColumnFit", false);
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
initialize(){
|
|
18
|
-
|
|
19
|
-
this.subscribe("cell-layout", this.layoutCellHandles.bind(this));
|
|
20
|
-
this.subscribe("column-init", this.layoutColumnHeader.bind(this));
|
|
21
|
-
// }
|
|
22
|
+
this.subscribe("column-rendered", this.layoutColumnHeader.bind(this));
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
initializeEventWatchers(){
|
|
26
|
+
if(!this.initialized){
|
|
27
|
+
|
|
28
|
+
this.subscribe("cell-rendered", this.layoutCellHandles.bind(this));
|
|
29
|
+
this.subscribe("cell-delete", this.deInitializeComponent.bind(this));
|
|
30
|
+
|
|
31
|
+
this.subscribe("cell-height", this.resizeHandle.bind(this));
|
|
32
|
+
this.subscribe("column-moved", this.columnLayoutUpdated.bind(this));
|
|
33
|
+
|
|
34
|
+
this.subscribe("column-hide", this.deInitializeColumn.bind(this));
|
|
35
|
+
this.subscribe("column-show", this.columnLayoutUpdated.bind(this));
|
|
36
|
+
|
|
37
|
+
this.subscribe("column-delete", this.deInitializeComponent.bind(this));
|
|
38
|
+
this.subscribe("column-height", this.resizeHandle.bind(this));
|
|
39
|
+
|
|
40
|
+
this.initialized = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
24
45
|
layoutCellHandles(cell){
|
|
25
46
|
if(cell.row.type === "row"){
|
|
26
|
-
this.
|
|
47
|
+
this.deInitializeComponent(cell);
|
|
48
|
+
this.initializeColumn("cell", cell, cell.column, cell.element);
|
|
27
49
|
}
|
|
28
50
|
}
|
|
29
51
|
|
|
30
52
|
layoutColumnHeader(column){
|
|
31
|
-
|
|
53
|
+
if(column.definition.resizable){
|
|
54
|
+
this.initializeEventWatchers();
|
|
55
|
+
this.deInitializeComponent(column);
|
|
56
|
+
this.initializeColumn("header", column, column, column.element);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
columnLayoutUpdated(column){
|
|
61
|
+
var prev = column.prevColumn();
|
|
62
|
+
|
|
63
|
+
this.reinitializeColumn(column);
|
|
64
|
+
|
|
65
|
+
if(prev){
|
|
66
|
+
this.reinitializeColumn(prev);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
reinitializeColumn(column){
|
|
71
|
+
column.cells.forEach((cell) => {
|
|
72
|
+
if(cell.modules.resize && cell.modules.resize.handleEl){
|
|
73
|
+
cell.element.after(cell.modules.resize.handleEl);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if(column.modules.resize && column.modules.resize.handleEl){
|
|
78
|
+
column.element.after(column.modules.resize.handleEl);
|
|
79
|
+
}
|
|
32
80
|
}
|
|
33
81
|
|
|
34
|
-
initializeColumn(type, column, element){
|
|
82
|
+
initializeColumn(type, component, column, element){
|
|
35
83
|
var self = this,
|
|
36
84
|
variableHeight = false,
|
|
37
|
-
mode = column.definition.resizable
|
|
85
|
+
mode = column.definition.resizable,
|
|
86
|
+
config = {},
|
|
87
|
+
nearestColumn = column.getLastColumn();
|
|
38
88
|
|
|
39
89
|
//set column resize mode
|
|
40
90
|
if(type === "header"){
|
|
41
91
|
variableHeight = column.definition.formatter == "textarea" || column.definition.variableHeight;
|
|
42
|
-
|
|
92
|
+
config = {variableHeight:variableHeight};
|
|
43
93
|
}
|
|
44
94
|
|
|
45
|
-
if(mode === true || mode == type){
|
|
95
|
+
if((mode === true || mode == type) && this._checkResizability(nearestColumn)){
|
|
46
96
|
|
|
47
97
|
var handle = document.createElement('div');
|
|
48
98
|
handle.className = "tabulator-col-resize-handle";
|
|
49
99
|
|
|
50
|
-
|
|
51
|
-
var prevHandle = document.createElement('div');
|
|
52
|
-
prevHandle.className = "tabulator-col-resize-handle prev";
|
|
53
|
-
|
|
54
100
|
handle.addEventListener("click", function(e){
|
|
55
101
|
e.stopPropagation();
|
|
56
102
|
});
|
|
57
103
|
|
|
58
104
|
var handleDown = function(e){
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
self.startColumn = column;
|
|
63
|
-
self._mouseDown(e, nearestColumn, handle);
|
|
64
|
-
}
|
|
105
|
+
self.startColumn = column;
|
|
106
|
+
self.initialNextColumn = self.nextColumn = nearestColumn.nextColumn();
|
|
107
|
+
self._mouseDown(e, nearestColumn, handle);
|
|
65
108
|
};
|
|
66
109
|
|
|
67
110
|
handle.addEventListener("mousedown", handleDown);
|
|
68
111
|
handle.addEventListener("touchstart", handleDown, {passive: true});
|
|
69
112
|
|
|
70
|
-
//
|
|
71
|
-
handle.addEventListener("dblclick",
|
|
72
|
-
var
|
|
73
|
-
oldWidth;
|
|
113
|
+
//resize column on double click
|
|
114
|
+
handle.addEventListener("dblclick", (e) => {
|
|
115
|
+
var oldWidth = nearestColumn.getWidth();
|
|
74
116
|
|
|
75
|
-
if(col && self._checkResizability(col)){
|
|
76
|
-
oldWidth = col.getWidth();
|
|
77
|
-
|
|
78
|
-
e.stopPropagation();
|
|
79
|
-
col.reinitializeWidth(true);
|
|
80
|
-
|
|
81
|
-
if(oldWidth !== col.getWidth()){
|
|
82
|
-
self.dispatch("column-resized", col);
|
|
83
|
-
self.table.externalEvents.dispatch("columnResized", col.getComponent());
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
prevHandle.addEventListener("click", function(e){
|
|
90
117
|
e.stopPropagation();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var prevHandleDown = function(e){
|
|
94
|
-
var nearestColumn, colIndex, prevColumn;
|
|
95
|
-
|
|
96
|
-
nearestColumn = column.getFirstColumn();
|
|
118
|
+
nearestColumn.reinitializeWidth(true);
|
|
97
119
|
|
|
98
|
-
if(nearestColumn){
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if(prevColumn && self._checkResizability(prevColumn)){
|
|
103
|
-
self.startColumn = column;
|
|
104
|
-
self._mouseDown(e, prevColumn, prevHandle);
|
|
105
|
-
}
|
|
120
|
+
if(oldWidth !== nearestColumn.getWidth()){
|
|
121
|
+
self.dispatch("column-resized", nearestColumn);
|
|
122
|
+
self.table.externalEvents.dispatch("columnResized", nearestColumn.getComponent());
|
|
106
123
|
}
|
|
107
|
-
};
|
|
124
|
+
});
|
|
108
125
|
|
|
109
|
-
|
|
110
|
-
prevHandle.addEventListener("touchstart", prevHandleDown, {passive: true});
|
|
126
|
+
config.handleEl = handle;
|
|
111
127
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
if(element.parentNode){
|
|
129
|
+
element.after(handle);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
component.modules.resize = config;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
deInitializeColumn(column){
|
|
137
|
+
this.deInitializeComponent(column);
|
|
138
|
+
|
|
139
|
+
column.cells.forEach((cell) => {
|
|
140
|
+
this.deInitializeComponent(cell);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
deInitializeComponent(component){
|
|
145
|
+
var handleEl;
|
|
146
|
+
|
|
147
|
+
if(component.modules.resize){
|
|
148
|
+
handleEl = component.modules.resize.handleEl;
|
|
128
149
|
|
|
129
|
-
|
|
130
|
-
|
|
150
|
+
if(handleEl && handleEl.parentElement){
|
|
151
|
+
handleEl.parentElement.removeChild(handleEl);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
resizeHandle(component, height){
|
|
157
|
+
if(component.modules.resize && component.modules.resize.handleEl){
|
|
158
|
+
component.modules.resize.handleEl.style.height = height;
|
|
131
159
|
}
|
|
132
160
|
}
|
|
133
161
|
|
|
@@ -139,14 +167,42 @@ class ResizeColumns extends Module{
|
|
|
139
167
|
var self = this;
|
|
140
168
|
|
|
141
169
|
self.table.element.classList.add("tabulator-block-select");
|
|
142
|
-
|
|
170
|
+
|
|
143
171
|
function mouseMove(e){
|
|
144
|
-
|
|
172
|
+
var x = typeof e.screenX === "undefined" ? e.touches[0].screenX : e.screenX,
|
|
173
|
+
startDiff = x - self.startX,
|
|
174
|
+
moveDiff = x - self.latestX,
|
|
175
|
+
blockedBefore, blockedAfter;
|
|
176
|
+
|
|
177
|
+
self.latestX = x;
|
|
145
178
|
|
|
146
179
|
if(self.table.rtl){
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
180
|
+
startDiff = -startDiff;
|
|
181
|
+
moveDiff = -moveDiff;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
blockedBefore = column.width == column.minWidth || column.width == column.maxWidth;
|
|
185
|
+
|
|
186
|
+
column.setWidth(self.startWidth + startDiff);
|
|
187
|
+
|
|
188
|
+
blockedAfter = column.width == column.minWidth || column.width == column.maxWidth;
|
|
189
|
+
|
|
190
|
+
if(moveDiff < 0){
|
|
191
|
+
self.nextColumn = self.initialNextColumn;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if(self.table.options.resizableColumnFit && self.nextColumn && !(blockedBefore && blockedAfter)){
|
|
195
|
+
let colWidth = self.nextColumn.getWidth();
|
|
196
|
+
|
|
197
|
+
if(moveDiff > 0){
|
|
198
|
+
if(colWidth <= self.nextColumn.minWidth){
|
|
199
|
+
self.nextColumn = self.nextColumn.nextColumn();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if(self.nextColumn){
|
|
204
|
+
self.nextColumn.setWidth(self.nextColumn.getWidth() - moveDiff);
|
|
205
|
+
}
|
|
150
206
|
}
|
|
151
207
|
|
|
152
208
|
self.table.columnManager.renderer.rerenderColumns(true);
|
|
@@ -174,7 +230,7 @@ class ResizeColumns extends Module{
|
|
|
174
230
|
handle.removeEventListener("touchend", mouseUp);
|
|
175
231
|
|
|
176
232
|
self.table.element.classList.remove("tabulator-block-select");
|
|
177
|
-
|
|
233
|
+
|
|
178
234
|
if(self.startWidth !== column.getWidth()){
|
|
179
235
|
self.dispatch("column-resized", column);
|
|
180
236
|
self.table.externalEvents.dispatch("columnResized", column.getComponent());
|
|
@@ -189,6 +245,7 @@ class ResizeColumns extends Module{
|
|
|
189
245
|
}
|
|
190
246
|
|
|
191
247
|
self.startX = typeof e.screenX === "undefined" ? e.touches[0].screenX : e.screenX;
|
|
248
|
+
self.latestX = self.startX;
|
|
192
249
|
self.startWidth = column.getWidth();
|
|
193
250
|
|
|
194
251
|
document.body.addEventListener("mousemove", mouseMove);
|
|
@@ -6,8 +6,21 @@ export default function(a, b, aRow, bRow, column, dir, params){
|
|
|
6
6
|
emptyAlign = 0;
|
|
7
7
|
|
|
8
8
|
if(typeof DT != "undefined"){
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if(DT.isDateTime(a)){
|
|
10
|
+
a = a;
|
|
11
|
+
}else if(inputFormat === "iso"){
|
|
12
|
+
a = DT.fromISO(String(a));
|
|
13
|
+
}else{
|
|
14
|
+
a = DT.fromFormat(String(a), inputFormat);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if(DT.isDateTime(b)){
|
|
18
|
+
b = b;
|
|
19
|
+
}else if(inputFormat === "iso"){
|
|
20
|
+
a = DT.fromISO(String(b));
|
|
21
|
+
}else{
|
|
22
|
+
b = DT.fromFormat(String(b), inputFormat);
|
|
23
|
+
}
|
|
11
24
|
|
|
12
25
|
if(!a.isValid){
|
|
13
26
|
emptyAlign = !b.isValid ? 0 : -1;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import Module from '../../core/Module.js';
|
|
2
|
+
import Cell from '../../core/cell/Cell.js';
|
|
3
|
+
|
|
4
|
+
class Tooltip extends Module{
|
|
5
|
+
|
|
6
|
+
constructor(table){
|
|
7
|
+
super(table);
|
|
8
|
+
|
|
9
|
+
this.tooltipSubscriber = null,
|
|
10
|
+
this.headerSubscriber = null,
|
|
11
|
+
|
|
12
|
+
this.timeout = null;
|
|
13
|
+
this.popupInstance = null;
|
|
14
|
+
|
|
15
|
+
this.registerTableOption("tooltipGenerationMode", undefined); //deprecated
|
|
16
|
+
this.registerTableOption("tooltipDelay", 300);
|
|
17
|
+
|
|
18
|
+
this.registerColumnOption("tooltip");
|
|
19
|
+
this.registerColumnOption("headerTooltip");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
initialize(){
|
|
23
|
+
this.deprecationCheck();
|
|
24
|
+
|
|
25
|
+
this.subscribe("column-init", this.initializeColumn.bind(this));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
deprecationCheck(){
|
|
29
|
+
if(typeof this.table.options.tooltipGenerationMode !== "undefined"){
|
|
30
|
+
console.warn("Use of the tooltipGenerationMode option is now deprecated. This option is no longer needed as tooltips are always generated on hover now");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
initializeColumn(column){
|
|
35
|
+
if(column.definition.headerTooltip && !this.headerSubscriber){
|
|
36
|
+
this.headerSubscriber = true;
|
|
37
|
+
|
|
38
|
+
this.subscribe("column-mousemove", this.mousemoveCheck.bind(this, "headerTooltip"));
|
|
39
|
+
this.subscribe("column-mouseout", this.mouseoutCheck.bind(this, "headerTooltip"));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if(column.definition.tooltip && !this.tooltipSubscriber){
|
|
43
|
+
this.tooltipSubscriber = true;
|
|
44
|
+
|
|
45
|
+
this.subscribe("cell-mousemove", this.mousemoveCheck.bind(this, "tooltip"));
|
|
46
|
+
this.subscribe("cell-mouseout", this.mouseoutCheck.bind(this, "tooltip"));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
mousemoveCheck(action, e, component){
|
|
51
|
+
var tooltip = action === "tooltip" ? component.column.definition.tooltip : component.definition.headerTooltip;
|
|
52
|
+
|
|
53
|
+
if(tooltip){
|
|
54
|
+
this.clearPopup();
|
|
55
|
+
this.timeout = setTimeout(this.loadTooltip.bind(this, e, component, tooltip), this.table.options.tooltipDelay);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
mouseoutCheck(action, e, component){
|
|
60
|
+
if(!this.popupInstance){
|
|
61
|
+
this.clearPopup();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
clearPopup(action, e, component){
|
|
66
|
+
clearTimeout(this.timeout);
|
|
67
|
+
this.timeout = null;
|
|
68
|
+
|
|
69
|
+
if(this.popupInstance){
|
|
70
|
+
this.popupInstance.hide();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
loadTooltip(e, component, tooltip){
|
|
75
|
+
var contentsEl, renderedCallback, coords;
|
|
76
|
+
|
|
77
|
+
function onRendered(callback){
|
|
78
|
+
renderedCallback = callback;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if(typeof tooltip === "function"){
|
|
82
|
+
tooltip = tooltip(e, component.getComponent(), onRendered);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if(tooltip instanceof HTMLElement){
|
|
86
|
+
contentsEl = tooltip;
|
|
87
|
+
}else{
|
|
88
|
+
contentsEl = document.createElement("div");
|
|
89
|
+
|
|
90
|
+
if(tooltip === true){
|
|
91
|
+
if(component instanceof Cell){
|
|
92
|
+
tooltip = component.value;
|
|
93
|
+
}else{
|
|
94
|
+
if(component.definition.field){
|
|
95
|
+
this.langBind("columns|" + component.definition.field, (value) => {
|
|
96
|
+
contentsEl.innerHTML = tooltip = value || component.definition.title;
|
|
97
|
+
});
|
|
98
|
+
}else{
|
|
99
|
+
tooltip = component.definition.title;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
contentsEl.innerHTML = tooltip;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if(tooltip || tooltip === 0 || tooltip === "0" || tooltip === false){
|
|
108
|
+
contentsEl.classList.add("tabulator-tooltip");
|
|
109
|
+
|
|
110
|
+
contentsEl.addEventListener("mousemove", e => e.preventDefault())
|
|
111
|
+
|
|
112
|
+
this.popupInstance = this.popup(contentsEl);
|
|
113
|
+
|
|
114
|
+
if(typeof renderedCallback === "function"){
|
|
115
|
+
this.popupInstance.renderCallback(renderedCallback);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
coords = this.popupInstance.containerEventCoords(e);
|
|
119
|
+
|
|
120
|
+
this.popupInstance.show(coords.x + 15, coords.y + 15).hideOnBlur(() => {
|
|
121
|
+
this.dispatchExternal("TooltipClosed", component.getComponent());
|
|
122
|
+
this.popupInstance = null;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
this.dispatchExternal("TooltipOpened", component.getComponent());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
Tooltip.moduleName = "tooltip";
|
|
131
|
+
|
|
132
|
+
export default Tooltip;
|