tabulator-tables 5.1.6 → 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/.github/ISSUE_TEMPLATE/bug_report.md +3 -2
- package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
- 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 +2550 -1663
- 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 +2827 -2147
- 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/rendering/renderers/VirtualDomHorizontal.js +6 -3
- package/src/js/core/row/Row.js +127 -118
- package/src/js/core/tools/Alert.js +63 -0
- package/src/js/core/tools/ComponentFunctionBinder.js +3 -3
- 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 +6 -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 -584
- 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 +10 -4
- 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 +59 -157
- 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
|
@@ -3,184 +3,222 @@ import Module from '../../core/Module.js';
|
|
|
3
3
|
import defaultValidators from './defaults/validators.js';
|
|
4
4
|
|
|
5
5
|
class Validate extends Module{
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
constructor(table){
|
|
8
8
|
super(table);
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
this.invalidCells = [];
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
this.registerTableOption("validationMode", "blocking");
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
this.registerColumnOption("validator");
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
this.registerTableFunction("getInvalidCells", this.getInvalidCells.bind(this));
|
|
17
17
|
this.registerTableFunction("clearCellValidation", this.userClearCellValidation.bind(this));
|
|
18
18
|
this.registerTableFunction("validate", this.userValidate.bind(this));
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
this.registerComponentFunction("cell", "isValid", this.cellIsValid.bind(this));
|
|
21
21
|
this.registerComponentFunction("cell", "clearValidation", this.clearValidation.bind(this));
|
|
22
22
|
this.registerComponentFunction("cell", "validate", this.cellValidate.bind(this));
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
this.registerComponentFunction("column", "validate", this.columnValidate.bind(this));
|
|
25
25
|
this.registerComponentFunction("row", "validate", this.rowValidate.bind(this));
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
29
|
initialize(){
|
|
30
30
|
this.subscribe("cell-delete", this.clearValidation.bind(this));
|
|
31
31
|
this.subscribe("column-layout", this.initializeColumnCheck.bind(this));
|
|
32
|
+
|
|
33
|
+
this.subscribe("edit-success", this.editValidate.bind(this));
|
|
34
|
+
this.subscribe("edit-editor-clear", this.editorClear.bind(this));
|
|
35
|
+
this.subscribe("edit-edited-clear", this.editedClear.bind(this));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
///////////////////////////////////
|
|
39
|
+
///////// Event Handling //////////
|
|
40
|
+
///////////////////////////////////
|
|
41
|
+
|
|
42
|
+
editValidate(cell, value, previousValue){
|
|
43
|
+
var valid = this.table.options.validationMode !== "manual" ? this.validate(cell.column.modules.validate, cell, value) : true;
|
|
44
|
+
|
|
45
|
+
// allow time for editor to make render changes then style cell
|
|
46
|
+
if(valid !== true){
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
cell.getElement().classList.add("tabulator-validation-fail");
|
|
49
|
+
this.dispatchExternal("validationFailed", cell.getComponent(), value, valid);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return valid;
|
|
32
54
|
}
|
|
55
|
+
|
|
56
|
+
editorClear(cell, cancelled){
|
|
57
|
+
if(cancelled){
|
|
58
|
+
if(cell.column.modules.validate){
|
|
59
|
+
this.cellValidate(cell);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
33
62
|
|
|
63
|
+
cell.getElement().classList.remove("tabulator-validation-fail");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
editedClear(cell){
|
|
67
|
+
if(cell.modules.validate){
|
|
68
|
+
cell.modules.validate.invalid = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
34
72
|
///////////////////////////////////
|
|
35
73
|
////////// Cell Functions /////////
|
|
36
74
|
///////////////////////////////////
|
|
37
|
-
|
|
75
|
+
|
|
38
76
|
cellIsValid(cell){
|
|
39
|
-
return cell.modules.validate ?
|
|
77
|
+
return cell.modules.validate ? (cell.modules.validate.invalid || true) : true;
|
|
40
78
|
}
|
|
41
|
-
|
|
79
|
+
|
|
42
80
|
cellValidate(cell){
|
|
43
81
|
return this.validate(cell.column.modules.validate, cell, cell.getValue());
|
|
44
82
|
}
|
|
45
|
-
|
|
83
|
+
|
|
46
84
|
///////////////////////////////////
|
|
47
85
|
///////// Column Functions ////////
|
|
48
86
|
///////////////////////////////////
|
|
49
|
-
|
|
87
|
+
|
|
50
88
|
columnValidate(column){
|
|
51
89
|
var invalid = [];
|
|
52
|
-
|
|
90
|
+
|
|
53
91
|
column.cells.forEach((cell) => {
|
|
54
92
|
if(!this.cellValidate(cell)){
|
|
55
93
|
invalid.push(cell.getComponent());
|
|
56
94
|
}
|
|
57
95
|
});
|
|
58
|
-
|
|
96
|
+
|
|
59
97
|
return invalid.length ? invalid : true;
|
|
60
98
|
}
|
|
61
|
-
|
|
99
|
+
|
|
62
100
|
///////////////////////////////////
|
|
63
101
|
////////// Row Functions //////////
|
|
64
102
|
///////////////////////////////////
|
|
65
|
-
|
|
103
|
+
|
|
66
104
|
rowValidate(row){
|
|
67
105
|
var invalid = [];
|
|
68
|
-
|
|
106
|
+
|
|
69
107
|
row.cells.forEach((cell) => {
|
|
70
108
|
if(!this.cellValidate(cell)){
|
|
71
109
|
invalid.push(cell.getComponent());
|
|
72
110
|
}
|
|
73
111
|
});
|
|
74
|
-
|
|
112
|
+
|
|
75
113
|
return invalid.length ? invalid : true;
|
|
76
114
|
}
|
|
77
|
-
|
|
115
|
+
|
|
78
116
|
///////////////////////////////////
|
|
79
117
|
///////// Table Functions /////////
|
|
80
118
|
///////////////////////////////////
|
|
81
|
-
|
|
82
|
-
|
|
119
|
+
|
|
120
|
+
|
|
83
121
|
userClearCellValidation(cells){
|
|
84
122
|
if(!cells){
|
|
85
123
|
cells = this.getInvalidCells();
|
|
86
124
|
}
|
|
87
|
-
|
|
125
|
+
|
|
88
126
|
if(!Array.isArray(cells)){
|
|
89
127
|
cells = [cells];
|
|
90
128
|
}
|
|
91
|
-
|
|
129
|
+
|
|
92
130
|
cells.forEach((cell) => {
|
|
93
131
|
this.clearValidation(cell._getSelf());
|
|
94
132
|
});
|
|
95
133
|
}
|
|
96
|
-
|
|
134
|
+
|
|
97
135
|
userValidate(cells){
|
|
98
136
|
var output = [];
|
|
99
|
-
|
|
137
|
+
|
|
100
138
|
//clear row data
|
|
101
139
|
this.table.rowManager.rows.forEach((row) => {
|
|
102
140
|
row = row.getComponent();
|
|
103
|
-
|
|
141
|
+
|
|
104
142
|
var valid = row.validate();
|
|
105
|
-
|
|
143
|
+
|
|
106
144
|
if(valid !== true){
|
|
107
145
|
output = output.concat(valid);
|
|
108
146
|
}
|
|
109
147
|
});
|
|
110
|
-
|
|
148
|
+
|
|
111
149
|
return output.length ? output : true;
|
|
112
150
|
}
|
|
113
|
-
|
|
151
|
+
|
|
114
152
|
///////////////////////////////////
|
|
115
153
|
///////// Internal Logic //////////
|
|
116
154
|
///////////////////////////////////
|
|
117
|
-
|
|
155
|
+
|
|
118
156
|
initializeColumnCheck(column){
|
|
119
157
|
if(typeof column.definition.validator !== "undefined"){
|
|
120
158
|
this.initializeColumn(column);
|
|
121
159
|
}
|
|
122
160
|
}
|
|
123
|
-
|
|
161
|
+
|
|
124
162
|
//validate
|
|
125
163
|
initializeColumn(column){
|
|
126
164
|
var self = this,
|
|
127
165
|
config = [],
|
|
128
166
|
validator;
|
|
129
|
-
|
|
167
|
+
|
|
130
168
|
if(column.definition.validator){
|
|
131
|
-
|
|
169
|
+
|
|
132
170
|
if(Array.isArray(column.definition.validator)){
|
|
133
171
|
column.definition.validator.forEach((item) => {
|
|
134
172
|
validator = self._extractValidator(item);
|
|
135
|
-
|
|
173
|
+
|
|
136
174
|
if(validator){
|
|
137
175
|
config.push(validator);
|
|
138
176
|
}
|
|
139
177
|
});
|
|
140
|
-
|
|
178
|
+
|
|
141
179
|
}else{
|
|
142
180
|
validator = this._extractValidator(column.definition.validator);
|
|
143
|
-
|
|
181
|
+
|
|
144
182
|
if(validator){
|
|
145
183
|
config.push(validator);
|
|
146
184
|
}
|
|
147
185
|
}
|
|
148
|
-
|
|
186
|
+
|
|
149
187
|
column.modules.validate = config.length ? config : false;
|
|
150
188
|
}
|
|
151
189
|
}
|
|
152
|
-
|
|
190
|
+
|
|
153
191
|
_extractValidator(value){
|
|
154
192
|
var type, params, pos;
|
|
155
|
-
|
|
193
|
+
|
|
156
194
|
switch(typeof value){
|
|
157
195
|
case "string":
|
|
158
196
|
pos = value.indexOf(':');
|
|
159
|
-
|
|
197
|
+
|
|
160
198
|
if(pos > -1){
|
|
161
199
|
type = value.substring(0,pos);
|
|
162
200
|
params = value.substring(pos+1);
|
|
163
201
|
}else{
|
|
164
202
|
type = value;
|
|
165
203
|
}
|
|
166
|
-
|
|
204
|
+
|
|
167
205
|
return this._buildValidator(type, params);
|
|
168
206
|
break;
|
|
169
|
-
|
|
207
|
+
|
|
170
208
|
case "function":
|
|
171
209
|
return this._buildValidator(value);
|
|
172
210
|
break;
|
|
173
|
-
|
|
211
|
+
|
|
174
212
|
case "object":
|
|
175
213
|
return this._buildValidator(value.type, value.parameters);
|
|
176
214
|
break;
|
|
177
215
|
}
|
|
178
216
|
}
|
|
179
|
-
|
|
217
|
+
|
|
180
218
|
_buildValidator(type, params){
|
|
181
|
-
|
|
219
|
+
|
|
182
220
|
var func = typeof type == "function" ? type : Validate.validators[type];
|
|
183
|
-
|
|
221
|
+
|
|
184
222
|
if(!func){
|
|
185
223
|
console.warn("Validator Setup Error - No matching validator found:", type);
|
|
186
224
|
return false;
|
|
@@ -192,71 +230,69 @@ class Validate extends Module{
|
|
|
192
230
|
};
|
|
193
231
|
}
|
|
194
232
|
}
|
|
195
|
-
|
|
233
|
+
|
|
196
234
|
validate(validators, cell, value){
|
|
197
235
|
var self = this,
|
|
198
|
-
|
|
236
|
+
failedValidators = [],
|
|
199
237
|
invalidIndex = this.invalidCells.indexOf(cell);
|
|
200
|
-
|
|
238
|
+
|
|
201
239
|
if(validators){
|
|
202
240
|
validators.forEach((item) => {
|
|
203
241
|
if(!item.func.call(self, cell.getComponent(), value, item.params)){
|
|
204
|
-
|
|
242
|
+
failedValidators.push({
|
|
205
243
|
type:item.type,
|
|
206
244
|
parameters:item.params
|
|
207
245
|
});
|
|
208
246
|
}
|
|
209
247
|
});
|
|
210
248
|
}
|
|
211
|
-
|
|
212
|
-
valid = valid.length ? valid : true;
|
|
213
|
-
|
|
249
|
+
|
|
214
250
|
if(!cell.modules.validate){
|
|
215
251
|
cell.modules.validate = {};
|
|
216
252
|
}
|
|
217
|
-
|
|
218
|
-
if(
|
|
253
|
+
|
|
254
|
+
if(!failedValidators.length){
|
|
219
255
|
cell.modules.validate.invalid = false;
|
|
220
256
|
cell.getElement().classList.remove("tabulator-validation-fail");
|
|
221
|
-
|
|
257
|
+
|
|
222
258
|
if(invalidIndex > -1){
|
|
223
259
|
this.invalidCells.splice(invalidIndex, 1);
|
|
224
260
|
}
|
|
225
261
|
}else{
|
|
226
|
-
cell.modules.validate.invalid =
|
|
227
|
-
|
|
262
|
+
cell.modules.validate.invalid = failedValidators;
|
|
263
|
+
|
|
228
264
|
if(this.table.options.validationMode !== "manual"){
|
|
229
265
|
cell.getElement().classList.add("tabulator-validation-fail");
|
|
230
266
|
}
|
|
231
|
-
|
|
267
|
+
|
|
232
268
|
if(invalidIndex == -1){
|
|
233
269
|
this.invalidCells.push(cell);
|
|
234
270
|
}
|
|
235
271
|
}
|
|
236
|
-
|
|
237
|
-
return
|
|
272
|
+
|
|
273
|
+
return failedValidators.length ? failedValidators : true;
|
|
238
274
|
}
|
|
239
|
-
|
|
275
|
+
|
|
240
276
|
getInvalidCells(){
|
|
241
277
|
var output = [];
|
|
242
|
-
|
|
278
|
+
|
|
243
279
|
this.invalidCells.forEach((cell) => {
|
|
244
280
|
output.push(cell.getComponent());
|
|
245
281
|
});
|
|
246
|
-
|
|
282
|
+
|
|
247
283
|
return output;
|
|
248
284
|
}
|
|
249
|
-
|
|
285
|
+
|
|
250
286
|
clearValidation(cell){
|
|
251
287
|
var invalidIndex;
|
|
252
|
-
|
|
288
|
+
|
|
253
289
|
if(cell.modules.validate && cell.modules.validate.invalid){
|
|
254
|
-
|
|
290
|
+
|
|
255
291
|
cell.getElement().classList.remove("tabulator-validation-fail");
|
|
256
292
|
cell.modules.validate.invalid = false;
|
|
257
|
-
|
|
293
|
+
|
|
258
294
|
invalidIndex = this.invalidCells.indexOf(cell);
|
|
259
|
-
|
|
295
|
+
|
|
260
296
|
if(invalidIndex > -1){
|
|
261
297
|
this.invalidCells.splice(invalidIndex, 1);
|
|
262
298
|
}
|