melondtable 1.15.3 → 1.16.4
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/dist/melondtable.cjs.js +249 -188
- package/dist/melondtable.css +9 -2
- package/dist/melondtable.js +329 -674
- package/dist/melondtable.min.css +1 -1
- package/dist/melondtable.min.js +1 -1
- package/package.json +4 -9
- package/src/cellmanager.js +9 -3
- package/src/columnmanager.js +5 -1
- package/src/datatable.js +24 -4
- package/src/defaults.js +65 -63
- package/src/rowmanager.js +9 -3
- package/src/style.css +5 -0
- package/src/style.js +3 -5
- package/src/translationmanager.js +30 -0
- package/src/translations/en.json +15 -0
- package/src/translations/fr.json +15 -0
- package/src/translations/index.js +15 -0
- package/src/translations/pt.json +15 -0
- package/src/translations/sw.json +15 -0
- package/src/translations/tr.json +15 -0
- package/src/utils.js +11 -0
package/dist/melondtable.cjs.js
CHANGED
|
@@ -710,7 +710,6 @@ function debounce(func, wait, options) {
|
|
|
710
710
|
}
|
|
711
711
|
if (maxing) {
|
|
712
712
|
// Handle invocations in a tight loop.
|
|
713
|
-
clearTimeout(timerId);
|
|
714
713
|
timerId = setTimeout(timerExpired, wait);
|
|
715
714
|
return invokeFunc(lastCallTime);
|
|
716
715
|
}
|
|
@@ -1903,6 +1902,16 @@ function numberSortAsc(a, b) {
|
|
|
1903
1902
|
function stripHTML(html) {
|
|
1904
1903
|
return html.replace(/<[^>]*>/g, '');
|
|
1905
1904
|
}
|
|
1905
|
+
function format(str, args) {
|
|
1906
|
+
if (!str) return str;
|
|
1907
|
+
|
|
1908
|
+
Object.keys(args).forEach(arg => {
|
|
1909
|
+
let regex = new RegExp(`{(${arg})}`, 'g');
|
|
1910
|
+
str = str.replace(regex, args[arg]);
|
|
1911
|
+
});
|
|
1912
|
+
|
|
1913
|
+
return str;
|
|
1914
|
+
}
|
|
1906
1915
|
|
|
1907
1916
|
class DataManager {
|
|
1908
1917
|
constructor(options) {
|
|
@@ -2656,7 +2665,10 @@ class CellManager {
|
|
|
2656
2665
|
bindCopyCellContents() {
|
|
2657
2666
|
this.keyboard.on('ctrl+c', () => {
|
|
2658
2667
|
const noOfCellsCopied = this.copyCellContents(this.$focusedCell, this.$selectionCursor);
|
|
2659
|
-
const message =
|
|
2668
|
+
const message = this.instance.translate('{count} cells copied', {
|
|
2669
|
+
count: noOfCellsCopied
|
|
2670
|
+
});
|
|
2671
|
+
|
|
2660
2672
|
if (noOfCellsCopied) {
|
|
2661
2673
|
this.instance.showToastMessage(message, 2);
|
|
2662
2674
|
}
|
|
@@ -3040,9 +3052,12 @@ class CellManager {
|
|
|
3040
3052
|
}
|
|
3041
3053
|
|
|
3042
3054
|
promise = valuePromise.then((value) => {
|
|
3043
|
-
const done = editor.setValue(value, rowIndex, col);
|
|
3044
3055
|
const oldValue = this.getCell(colIndex, rowIndex).content;
|
|
3045
3056
|
|
|
3057
|
+
if (oldValue === value) return false;
|
|
3058
|
+
|
|
3059
|
+
const done = editor.setValue(value, rowIndex, col);
|
|
3060
|
+
|
|
3046
3061
|
// update cell immediately
|
|
3047
3062
|
this.updateCell(colIndex, rowIndex, value);
|
|
3048
3063
|
$cell.focus();
|
|
@@ -3163,7 +3178,7 @@ class CellManager {
|
|
|
3163
3178
|
}
|
|
3164
3179
|
|
|
3165
3180
|
focusCellInDirection(direction) {
|
|
3166
|
-
if (!this.$focusedCell) {
|
|
3181
|
+
if (!this.$focusedCell || (this.$editingCell && ['left', 'right', 'up', 'down'].includes(direction))) {
|
|
3167
3182
|
return false;
|
|
3168
3183
|
} else if (this.$editingCell && ['tab', 'shift+tab'].includes(direction)) {
|
|
3169
3184
|
this.deactivateEditing();
|
|
@@ -3573,7 +3588,11 @@ class ColumnManager {
|
|
|
3573
3588
|
|
|
3574
3589
|
const onMouseMove = (e) => {
|
|
3575
3590
|
if (!isDragging) return;
|
|
3576
|
-
|
|
3591
|
+
let delta = e.pageX - startX;
|
|
3592
|
+
if (this.options.direction === 'rtl') {
|
|
3593
|
+
delta = -1 * delta;
|
|
3594
|
+
}
|
|
3595
|
+
const finalWidth = startWidth + delta;
|
|
3577
3596
|
const {
|
|
3578
3597
|
colIndex
|
|
3579
3598
|
} = $.data($resizingCell);
|
|
@@ -3974,7 +3993,10 @@ class RowManager {
|
|
|
3974
3993
|
const checkedRows = this.getCheckedRows();
|
|
3975
3994
|
const count = checkedRows.length;
|
|
3976
3995
|
if (count > 0) {
|
|
3977
|
-
this.
|
|
3996
|
+
let message = this.instance.translate('{count} rows selected', {
|
|
3997
|
+
count: count
|
|
3998
|
+
});
|
|
3999
|
+
this.bodyRenderer.showToastMessage(message);
|
|
3978
4000
|
} else {
|
|
3979
4001
|
this.bodyRenderer.clearToastMessage();
|
|
3980
4002
|
}
|
|
@@ -4166,7 +4188,8 @@ class RowManager {
|
|
|
4166
4188
|
if (props.isFilter) {
|
|
4167
4189
|
row = row.map(cell => (Object.assign({}, cell, {
|
|
4168
4190
|
content: this.getFilterInput({
|
|
4169
|
-
colIndex: cell.colIndex
|
|
4191
|
+
colIndex: cell.colIndex,
|
|
4192
|
+
name: cell.name
|
|
4170
4193
|
}),
|
|
4171
4194
|
isFilter: 1,
|
|
4172
4195
|
isHeader: undefined,
|
|
@@ -4188,8 +4211,10 @@ class RowManager {
|
|
|
4188
4211
|
}
|
|
4189
4212
|
|
|
4190
4213
|
getFilterInput(props) {
|
|
4214
|
+
let title = `title="Filter based on ${props.name || 'Index'}"`;
|
|
4191
4215
|
const dataAttr = makeDataAttributeString(props);
|
|
4192
|
-
return `<input class="dt-filter dt-input" type="text" ${dataAttr} tabindex="1"
|
|
4216
|
+
return `<input class="dt-filter dt-input" type="text" ${dataAttr} tabindex="1"
|
|
4217
|
+
${props.colIndex === 0 ? 'disabled' : title} />`;
|
|
4193
4218
|
}
|
|
4194
4219
|
|
|
4195
4220
|
selector(rowIndex) {
|
|
@@ -4198,7 +4223,7 @@ class RowManager {
|
|
|
4198
4223
|
}
|
|
4199
4224
|
|
|
4200
4225
|
var hyperlist = createCommonjsModule(function (module, exports) {
|
|
4201
|
-
(function(f){{module.exports=f();}})(function(){return (function
|
|
4226
|
+
(function(f){{module.exports=f();}})(function(){return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof commonjsRequire=="function"&&commonjsRequire;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r);}return n[o].exports}var i=typeof commonjsRequire=="function"&&commonjsRequire;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
|
4202
4227
|
|
|
4203
4228
|
// Default configuration.
|
|
4204
4229
|
|
|
@@ -4208,25 +4233,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4208
4233
|
|
|
4209
4234
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4210
4235
|
|
|
4211
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4212
|
-
|
|
4213
4236
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4214
4237
|
|
|
4215
4238
|
var defaultConfig = {
|
|
4216
4239
|
width: '100%',
|
|
4217
4240
|
height: '100%'
|
|
4218
|
-
|
|
4219
|
-
// Check for valid number.
|
|
4220
|
-
};var isNumber = function isNumber(input) {
|
|
4221
|
-
return Number(input) === Number(input);
|
|
4222
4241
|
};
|
|
4223
4242
|
|
|
4224
|
-
//
|
|
4225
|
-
var
|
|
4226
|
-
|
|
4227
|
-
} : function (element, className) {
|
|
4228
|
-
var oldClass = element.getAttribute('class') || '';
|
|
4229
|
-
element.setAttribute('class', oldClass + ' ' + className);
|
|
4243
|
+
// Check for valid number.
|
|
4244
|
+
var isNumber = function isNumber(input) {
|
|
4245
|
+
return Number(input) === Number(input);
|
|
4230
4246
|
};
|
|
4231
4247
|
|
|
4232
4248
|
/**
|
|
@@ -4311,8 +4327,7 @@ var HyperList = function () {
|
|
|
4311
4327
|
return;
|
|
4312
4328
|
}
|
|
4313
4329
|
|
|
4314
|
-
|
|
4315
|
-
if (!lastRepaint || diff < 0 || diff > _this._averageHeight) {
|
|
4330
|
+
if (!lastRepaint || Math.abs(scrollTop - lastRepaint) > _this._averageHeight) {
|
|
4316
4331
|
var rendered = _this._renderChunk();
|
|
4317
4332
|
|
|
4318
4333
|
_this._lastRepaint = scrollTop;
|
|
@@ -4334,7 +4349,7 @@ var HyperList = function () {
|
|
|
4334
4349
|
}, {
|
|
4335
4350
|
key: 'refresh',
|
|
4336
4351
|
value: function refresh(element, userProvidedConfig) {
|
|
4337
|
-
var
|
|
4352
|
+
var _this2 = this;
|
|
4338
4353
|
|
|
4339
4354
|
Object.assign(this._config, defaultConfig, userProvidedConfig);
|
|
4340
4355
|
|
|
@@ -4376,6 +4391,7 @@ var HyperList = function () {
|
|
|
4376
4391
|
}).forEach(function (prop) {
|
|
4377
4392
|
var value = config[prop];
|
|
4378
4393
|
var isValueNumber = isNumber(value);
|
|
4394
|
+
var isValuePercent = isValueNumber ? false : value.slice(-1) === '%';
|
|
4379
4395
|
|
|
4380
4396
|
if (value && typeof value !== 'string' && typeof value !== 'number') {
|
|
4381
4397
|
var msg = 'Invalid optional `' + prop + '`, expected string or number';
|
|
@@ -4383,52 +4399,45 @@ var HyperList = function () {
|
|
|
4383
4399
|
} else if (isValueNumber) {
|
|
4384
4400
|
config[prop] = value + 'px';
|
|
4385
4401
|
}
|
|
4386
|
-
});
|
|
4387
4402
|
|
|
4388
|
-
|
|
4389
|
-
|
|
4403
|
+
if (prop !== 'height') {
|
|
4404
|
+
return;
|
|
4405
|
+
}
|
|
4390
4406
|
|
|
4391
|
-
if (value) {
|
|
4392
|
-
var isValueNumber = isNumber(value);
|
|
4393
|
-
var isValuePercent = isValueNumber ? false : value.slice(-1) === '%';
|
|
4394
4407
|
// Compute the containerHeight as number
|
|
4395
4408
|
var numberValue = isValueNumber ? value : parseInt(value.replace(/px|%/, ''), 10);
|
|
4396
|
-
var innerSize = window[isHoriz ? 'innerWidth' : 'innerHeight'];
|
|
4397
4409
|
|
|
4398
4410
|
if (isValuePercent) {
|
|
4399
|
-
|
|
4411
|
+
_this2._containerHeight = window.innerHeight * numberValue / 100;
|
|
4400
4412
|
} else {
|
|
4401
|
-
|
|
4413
|
+
_this2._containerHeight = isNumber(value) ? value : numberValue;
|
|
4402
4414
|
}
|
|
4403
|
-
}
|
|
4404
|
-
|
|
4405
|
-
var scrollContainer = config.scrollContainer;
|
|
4406
|
-
var scrollerHeight = config.itemHeight * config.total;
|
|
4407
|
-
var maxElementHeight = this._maxElementHeight;
|
|
4408
|
-
|
|
4409
|
-
if (scrollerHeight > maxElementHeight) {
|
|
4410
|
-
console.warn(['HyperList: The maximum element height', maxElementHeight + 'px has', 'been exceeded; please reduce your item height.'].join(' '));
|
|
4411
|
-
}
|
|
4415
|
+
});
|
|
4412
4416
|
|
|
4413
4417
|
// Decorate the container element with styles that will match
|
|
4414
4418
|
// the user supplied configuration.
|
|
4415
4419
|
var elementStyle = {
|
|
4416
4420
|
width: '' + config.width,
|
|
4417
|
-
height:
|
|
4418
|
-
overflow:
|
|
4421
|
+
height: '' + config.height,
|
|
4422
|
+
overflow: 'auto',
|
|
4419
4423
|
position: 'relative'
|
|
4420
4424
|
};
|
|
4421
4425
|
|
|
4422
4426
|
HyperList.mergeStyle(element, elementStyle);
|
|
4423
4427
|
|
|
4424
|
-
|
|
4425
|
-
|
|
4428
|
+
var scrollerHeight = config.itemHeight * config.total;
|
|
4429
|
+
var maxElementHeight = this._maxElementHeight;
|
|
4430
|
+
|
|
4431
|
+
if (scrollerHeight > maxElementHeight) {
|
|
4432
|
+
console.warn(['HyperList: The maximum element height', maxElementHeight + 'px has', 'been exceeded; please reduce your item height.'].join(' '));
|
|
4426
4433
|
}
|
|
4427
4434
|
|
|
4428
|
-
var scrollerStyle =
|
|
4435
|
+
var scrollerStyle = {
|
|
4429
4436
|
opacity: '0',
|
|
4430
|
-
position: 'absolute'
|
|
4431
|
-
|
|
4437
|
+
position: 'absolute',
|
|
4438
|
+
width: '1px',
|
|
4439
|
+
height: scrollerHeight + 'px'
|
|
4440
|
+
};
|
|
4432
4441
|
|
|
4433
4442
|
HyperList.mergeStyle(scroller, scrollerStyle);
|
|
4434
4443
|
|
|
@@ -4437,10 +4446,6 @@ var HyperList = function () {
|
|
|
4437
4446
|
element.appendChild(scroller);
|
|
4438
4447
|
}
|
|
4439
4448
|
|
|
4440
|
-
var padding = this._computeScrollPadding();
|
|
4441
|
-
this._scrollPaddingBottom = padding.bottom;
|
|
4442
|
-
this._scrollPaddingTop = padding.top;
|
|
4443
|
-
|
|
4444
4449
|
// Set the scroller instance.
|
|
4445
4450
|
this._scroller = scroller;
|
|
4446
4451
|
this._scrollHeight = this._computeScrollHeight();
|
|
@@ -4469,7 +4474,7 @@ var HyperList = function () {
|
|
|
4469
4474
|
item = item.element;
|
|
4470
4475
|
|
|
4471
4476
|
// The height isn't the same as predicted, compute positions again
|
|
4472
|
-
if (height !== this._itemHeights
|
|
4477
|
+
if (height !== this._itemHeights) {
|
|
4473
4478
|
this._itemHeights[i] = height;
|
|
4474
4479
|
this._computePositions(i);
|
|
4475
4480
|
this._scrollHeight = this._computeScrollHeight(i);
|
|
@@ -4482,13 +4487,15 @@ var HyperList = function () {
|
|
|
4482
4487
|
throw new Error('Generator did not return a DOM Node for index: ' + i);
|
|
4483
4488
|
}
|
|
4484
4489
|
|
|
4485
|
-
|
|
4490
|
+
var oldClass = item.getAttribute('class') || '';
|
|
4491
|
+
item.setAttribute('class', oldClass + ' ' + (config.rowClassName || 'vrow'));
|
|
4486
4492
|
|
|
4487
|
-
var top = this._itemPositions[i]
|
|
4493
|
+
var top = this._itemPositions[i];
|
|
4488
4494
|
|
|
4489
|
-
HyperList.mergeStyle(item,
|
|
4490
|
-
position: 'absolute'
|
|
4491
|
-
|
|
4495
|
+
HyperList.mergeStyle(item, {
|
|
4496
|
+
position: 'absolute',
|
|
4497
|
+
top: top + 'px'
|
|
4498
|
+
});
|
|
4492
4499
|
|
|
4493
4500
|
return item;
|
|
4494
4501
|
}
|
|
@@ -4501,7 +4508,7 @@ var HyperList = function () {
|
|
|
4501
4508
|
return config.overrideScrollPosition();
|
|
4502
4509
|
}
|
|
4503
4510
|
|
|
4504
|
-
return this._element
|
|
4511
|
+
return this._element.scrollTop;
|
|
4505
4512
|
}
|
|
4506
4513
|
}, {
|
|
4507
4514
|
key: '_renderChunk',
|
|
@@ -4558,7 +4565,7 @@ var HyperList = function () {
|
|
|
4558
4565
|
}, {
|
|
4559
4566
|
key: '_computePositions',
|
|
4560
4567
|
value: function _computePositions() {
|
|
4561
|
-
var from = arguments.length
|
|
4568
|
+
var from = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0];
|
|
4562
4569
|
|
|
4563
4570
|
var config = this._config;
|
|
4564
4571
|
var total = config.total;
|
|
@@ -4583,21 +4590,20 @@ var HyperList = function () {
|
|
|
4583
4590
|
}, {
|
|
4584
4591
|
key: '_computeScrollHeight',
|
|
4585
4592
|
value: function _computeScrollHeight() {
|
|
4586
|
-
var
|
|
4587
|
-
_this2 = this;
|
|
4593
|
+
var _this3 = this;
|
|
4588
4594
|
|
|
4589
4595
|
var config = this._config;
|
|
4590
|
-
var isHoriz = Boolean(config.horizontal);
|
|
4591
4596
|
var total = config.total;
|
|
4592
4597
|
var scrollHeight = this._itemHeights.reduce(function (a, b) {
|
|
4593
4598
|
return a + b;
|
|
4594
|
-
}, 0)
|
|
4599
|
+
}, 0);
|
|
4595
4600
|
|
|
4596
|
-
HyperList.mergeStyle(this._scroller,
|
|
4601
|
+
HyperList.mergeStyle(this._scroller, {
|
|
4597
4602
|
opacity: 0,
|
|
4598
4603
|
position: 'absolute',
|
|
4599
|
-
|
|
4600
|
-
|
|
4604
|
+
width: '1px',
|
|
4605
|
+
height: scrollHeight + 'px'
|
|
4606
|
+
});
|
|
4601
4607
|
|
|
4602
4608
|
// Calculate the height median
|
|
4603
4609
|
var sortedItemHeights = this._itemHeights.slice(0).sort(function (a, b) {
|
|
@@ -4606,11 +4612,9 @@ var HyperList = function () {
|
|
|
4606
4612
|
var middle = Math.floor(total / 2);
|
|
4607
4613
|
var averageHeight = total % 2 === 0 ? (sortedItemHeights[middle] + sortedItemHeights[middle - 1]) / 2 : sortedItemHeights[middle];
|
|
4608
4614
|
|
|
4609
|
-
var
|
|
4610
|
-
var element = config.scrollContainer ? config.scrollContainer : this._element;
|
|
4611
|
-
var containerHeight = element[clientProp] ? element[clientProp] : this._containerSize;
|
|
4615
|
+
var containerHeight = this._element.clientHeight ? this._element.clientHeight : this._containerHeight;
|
|
4612
4616
|
this._screenItemsLen = Math.ceil(containerHeight / averageHeight);
|
|
4613
|
-
this.
|
|
4617
|
+
this._containerHeight = containerHeight;
|
|
4614
4618
|
|
|
4615
4619
|
// Cache 3 times the number of items that fit in the container viewport.
|
|
4616
4620
|
this._cachedItemsLen = Math.max(this._cachedItemsLen || 0, this._screenItemsLen * 3);
|
|
@@ -4618,51 +4622,12 @@ var HyperList = function () {
|
|
|
4618
4622
|
|
|
4619
4623
|
if (config.reverse) {
|
|
4620
4624
|
window.requestAnimationFrame(function () {
|
|
4621
|
-
|
|
4622
|
-
_this2._element.scrollLeft = scrollHeight;
|
|
4623
|
-
} else {
|
|
4624
|
-
_this2._element.scrollTop = scrollHeight;
|
|
4625
|
-
}
|
|
4625
|
+
_this3._element.scrollTop = scrollHeight;
|
|
4626
4626
|
});
|
|
4627
4627
|
}
|
|
4628
4628
|
|
|
4629
4629
|
return scrollHeight;
|
|
4630
4630
|
}
|
|
4631
|
-
}, {
|
|
4632
|
-
key: '_computeScrollPadding',
|
|
4633
|
-
value: function _computeScrollPadding() {
|
|
4634
|
-
var config = this._config;
|
|
4635
|
-
var isHoriz = Boolean(config.horizontal);
|
|
4636
|
-
var isReverse = config.reverse;
|
|
4637
|
-
var styles = window.getComputedStyle(this._element);
|
|
4638
|
-
|
|
4639
|
-
var padding = function padding(location) {
|
|
4640
|
-
var cssValue = styles.getPropertyValue('padding-' + location);
|
|
4641
|
-
return parseInt(cssValue, 10) || 0;
|
|
4642
|
-
};
|
|
4643
|
-
|
|
4644
|
-
if (isHoriz && isReverse) {
|
|
4645
|
-
return {
|
|
4646
|
-
bottom: padding('left'),
|
|
4647
|
-
top: padding('right')
|
|
4648
|
-
};
|
|
4649
|
-
} else if (isHoriz) {
|
|
4650
|
-
return {
|
|
4651
|
-
bottom: padding('right'),
|
|
4652
|
-
top: padding('left')
|
|
4653
|
-
};
|
|
4654
|
-
} else if (isReverse) {
|
|
4655
|
-
return {
|
|
4656
|
-
bottom: padding('top'),
|
|
4657
|
-
top: padding('bottom')
|
|
4658
|
-
};
|
|
4659
|
-
} else {
|
|
4660
|
-
return {
|
|
4661
|
-
bottom: padding('bottom'),
|
|
4662
|
-
top: padding('top')
|
|
4663
|
-
};
|
|
4664
|
-
}
|
|
4665
|
-
}
|
|
4666
4631
|
}, {
|
|
4667
4632
|
key: '_getFrom',
|
|
4668
4633
|
value: function _getFrom(scrollTop) {
|
|
@@ -4679,7 +4644,7 @@ var HyperList = function () {
|
|
|
4679
4644
|
value: function _getReverseFrom(scrollTop) {
|
|
4680
4645
|
var i = this._config.total - 1;
|
|
4681
4646
|
|
|
4682
|
-
while (i > 0 && this._itemPositions[i] < scrollTop + this.
|
|
4647
|
+
while (i > 0 && this._itemPositions[i] < scrollTop + this._containerHeight) {
|
|
4683
4648
|
i--;
|
|
4684
4649
|
}
|
|
4685
4650
|
|
|
@@ -5030,11 +4995,6 @@ class Style {
|
|
|
5030
4995
|
|
|
5031
4996
|
let naturalWidth = $.style($('.dt-cell__content', $cell), 'width');
|
|
5032
4997
|
|
|
5033
|
-
if (column.id === '_rowIndex') {
|
|
5034
|
-
naturalWidth = this.getRowIndexColumnWidth();
|
|
5035
|
-
column.width = naturalWidth;
|
|
5036
|
-
}
|
|
5037
|
-
|
|
5038
4998
|
if (typeof naturalWidth === 'number' && naturalWidth >= column.naturalWidth) {
|
|
5039
4999
|
column.naturalWidth = naturalWidth;
|
|
5040
5000
|
} else {
|
|
@@ -5083,6 +5043,9 @@ class Style {
|
|
|
5083
5043
|
if (!column.width) {
|
|
5084
5044
|
column.width = column.naturalWidth;
|
|
5085
5045
|
}
|
|
5046
|
+
if (column.id === '_rowIndex') {
|
|
5047
|
+
column.width = this.getRowIndexColumnWidth();
|
|
5048
|
+
}
|
|
5086
5049
|
if (column.width < this.options.minimumColumnWidth) {
|
|
5087
5050
|
column.width = this.options.minimumColumnWidth;
|
|
5088
5051
|
}
|
|
@@ -5268,6 +5231,83 @@ class Keyboard {
|
|
|
5268
5231
|
}
|
|
5269
5232
|
}
|
|
5270
5233
|
|
|
5234
|
+
var en = {
|
|
5235
|
+
"Sort Ascending": "Sort Ascending",
|
|
5236
|
+
"Sort Descending": "Sort Descending",
|
|
5237
|
+
"Reset sorting": "Reset sorting",
|
|
5238
|
+
"Remove column": "Remove column",
|
|
5239
|
+
"No Data": "No Data",
|
|
5240
|
+
"{count} cells copied": {"1":"{count} cell copied","default":"{count} cells copied"},
|
|
5241
|
+
"{count} rows selected": {"1":"{count} row selected","default":"{count} rows selected"}
|
|
5242
|
+
};
|
|
5243
|
+
|
|
5244
|
+
var de = {
|
|
5245
|
+
"Sort Ascending": "Aufsteigend sortieren",
|
|
5246
|
+
"Sort Descending": "Absteigend sortieren",
|
|
5247
|
+
"Reset sorting": "Sortierung zurücksetzen",
|
|
5248
|
+
"Remove column": "Spalte entfernen",
|
|
5249
|
+
"No Data": "Keine Daten",
|
|
5250
|
+
"{count} cells copied": {"1":"{count} Zelle kopiert","default":"{count} Zellen kopiert"},
|
|
5251
|
+
"{count} rows selected": {"1":"{count} Zeile ausgewählt","default":"{count} Zeilen ausgewählt"}
|
|
5252
|
+
};
|
|
5253
|
+
|
|
5254
|
+
var fr = {
|
|
5255
|
+
"Sort Ascending": "Trier par ordre croissant",
|
|
5256
|
+
"Sort Descending": "Trier par ordre décroissant",
|
|
5257
|
+
"Reset sorting": "Réinitialiser le tri",
|
|
5258
|
+
"Remove column": "Supprimer colonne",
|
|
5259
|
+
"No Data": "Pas de données",
|
|
5260
|
+
"{count} cells copied": {"1":"{count} cellule copiée","default":"{count} cellules copiées"},
|
|
5261
|
+
"{count} rows selected": {"1":"{count} ligne sélectionnée","default":"{count} lignes sélectionnées"}
|
|
5262
|
+
};
|
|
5263
|
+
|
|
5264
|
+
var it = {
|
|
5265
|
+
"Sort Ascending": "Ordinamento ascendente",
|
|
5266
|
+
"Sort Descending": "Ordinamento decrescente",
|
|
5267
|
+
"Reset sorting": "Azzeramento ordinamento",
|
|
5268
|
+
"Remove column": "Rimuovi colonna",
|
|
5269
|
+
"No Data": "Nessun dato",
|
|
5270
|
+
"{count} cells copied": {"1":"Copiato {count} cella","default":"{count} celle copiate"},
|
|
5271
|
+
"{count} rows selected": {"1":"{count} linea selezionata","default":"{count} linee selezionate"}
|
|
5272
|
+
};
|
|
5273
|
+
|
|
5274
|
+
function getTranslations() {
|
|
5275
|
+
return {
|
|
5276
|
+
en,
|
|
5277
|
+
de,
|
|
5278
|
+
fr,
|
|
5279
|
+
it,
|
|
5280
|
+
};
|
|
5281
|
+
}
|
|
5282
|
+
|
|
5283
|
+
class TranslationManager {
|
|
5284
|
+
constructor(language) {
|
|
5285
|
+
this.language = language;
|
|
5286
|
+
this.translations = getTranslations();
|
|
5287
|
+
}
|
|
5288
|
+
|
|
5289
|
+
addTranslations(translations) {
|
|
5290
|
+
this.translations = Object.assign(this.translations, translations);
|
|
5291
|
+
}
|
|
5292
|
+
|
|
5293
|
+
translate(sourceText, args) {
|
|
5294
|
+
let translation = (this.translations[this.language] &&
|
|
5295
|
+
this.translations[this.language][sourceText]) || sourceText;
|
|
5296
|
+
|
|
5297
|
+
if (typeof translation === 'object') {
|
|
5298
|
+
translation = args && args.count ?
|
|
5299
|
+
this.getPluralizedTranslation(translation, args.count) :
|
|
5300
|
+
sourceText;
|
|
5301
|
+
}
|
|
5302
|
+
|
|
5303
|
+
return format(translation, args || {});
|
|
5304
|
+
}
|
|
5305
|
+
|
|
5306
|
+
getPluralizedTranslation(translations, count) {
|
|
5307
|
+
return translations[count] || translations['default'];
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
|
|
5271
5311
|
function filterRows(rows, filters) {
|
|
5272
5312
|
let filteredRowIndices = [];
|
|
5273
5313
|
|
|
@@ -5460,74 +5500,76 @@ function guessFilter(keyword = '') {
|
|
|
5460
5500
|
};
|
|
5461
5501
|
}
|
|
5462
5502
|
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5503
|
+
function getDefaultOptions(instance) {
|
|
5504
|
+
return {
|
|
5505
|
+
columns: [],
|
|
5506
|
+
data: [],
|
|
5507
|
+
dropdownButton: icons.chevronDown,
|
|
5508
|
+
headerDropdown: [
|
|
5509
|
+
{
|
|
5510
|
+
label: instance.translate('Sort Ascending'),
|
|
5511
|
+
action: function (column) {
|
|
5512
|
+
this.sortColumn(column.colIndex, 'asc');
|
|
5513
|
+
}
|
|
5514
|
+
},
|
|
5515
|
+
{
|
|
5516
|
+
label: instance.translate('Sort Descending'),
|
|
5517
|
+
action: function (column) {
|
|
5518
|
+
this.sortColumn(column.colIndex, 'desc');
|
|
5519
|
+
}
|
|
5520
|
+
},
|
|
5521
|
+
{
|
|
5522
|
+
label: instance.translate('Reset sorting'),
|
|
5523
|
+
action: function (column) {
|
|
5524
|
+
this.sortColumn(column.colIndex, 'none');
|
|
5525
|
+
}
|
|
5526
|
+
},
|
|
5527
|
+
{
|
|
5528
|
+
label: instance.translate('Remove column'),
|
|
5529
|
+
action: function (column) {
|
|
5530
|
+
this.removeColumn(column.colIndex);
|
|
5531
|
+
}
|
|
5472
5532
|
}
|
|
5533
|
+
],
|
|
5534
|
+
events: {
|
|
5535
|
+
onRemoveColumn(column) {},
|
|
5536
|
+
onSwitchColumn(column1, column2) {},
|
|
5537
|
+
onSortColumn(column) {},
|
|
5538
|
+
onCheckRow(row) {},
|
|
5539
|
+
onDestroy() {}
|
|
5473
5540
|
},
|
|
5474
|
-
{
|
|
5475
|
-
|
|
5476
|
-
action: function (column) {
|
|
5477
|
-
this.sortColumn(column.colIndex, 'desc');
|
|
5478
|
-
}
|
|
5541
|
+
hooks: {
|
|
5542
|
+
columnTotal: null
|
|
5479
5543
|
},
|
|
5480
|
-
{
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
}
|
|
5544
|
+
sortIndicator: {
|
|
5545
|
+
asc: '↑',
|
|
5546
|
+
desc: '↓',
|
|
5547
|
+
none: ''
|
|
5485
5548
|
},
|
|
5486
|
-
{
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
},
|
|
5511
|
-
filterRows: filterRows,
|
|
5512
|
-
freezeMessage: '',
|
|
5513
|
-
getEditor: null,
|
|
5514
|
-
serialNoColumn: true,
|
|
5515
|
-
checkboxColumn: false,
|
|
5516
|
-
clusterize: true,
|
|
5517
|
-
logs: false,
|
|
5518
|
-
layout: 'fixed', // fixed, fluid, ratio
|
|
5519
|
-
noDataMessage: 'No Data',
|
|
5520
|
-
cellHeight: 40,
|
|
5521
|
-
minimumColumnWidth: 30,
|
|
5522
|
-
inlineFilters: false,
|
|
5523
|
-
treeView: false,
|
|
5524
|
-
checkedRowStatus: true,
|
|
5525
|
-
dynamicRowHeight: false,
|
|
5526
|
-
pasteFromClipboard: false,
|
|
5527
|
-
showTotalRow: false,
|
|
5528
|
-
direction: 'ltr',
|
|
5529
|
-
disableReorderColumn: false
|
|
5530
|
-
};
|
|
5549
|
+
overrideComponents: {
|
|
5550
|
+
// ColumnManager: CustomColumnManager
|
|
5551
|
+
},
|
|
5552
|
+
filterRows: filterRows,
|
|
5553
|
+
freezeMessage: '',
|
|
5554
|
+
getEditor: null,
|
|
5555
|
+
serialNoColumn: true,
|
|
5556
|
+
checkboxColumn: false,
|
|
5557
|
+
clusterize: true,
|
|
5558
|
+
logs: false,
|
|
5559
|
+
layout: 'fixed', // fixed, fluid, ratio
|
|
5560
|
+
noDataMessage: instance.translate('No Data'),
|
|
5561
|
+
cellHeight: 40,
|
|
5562
|
+
minimumColumnWidth: 30,
|
|
5563
|
+
inlineFilters: false,
|
|
5564
|
+
treeView: false,
|
|
5565
|
+
checkedRowStatus: true,
|
|
5566
|
+
dynamicRowHeight: false,
|
|
5567
|
+
pasteFromClipboard: false,
|
|
5568
|
+
showTotalRow: false,
|
|
5569
|
+
direction: 'ltr',
|
|
5570
|
+
disableReorderColumn: false
|
|
5571
|
+
};
|
|
5572
|
+
}
|
|
5531
5573
|
|
|
5532
5574
|
let defaultComponents = {
|
|
5533
5575
|
DataManager,
|
|
@@ -5552,6 +5594,8 @@ class DataTable {
|
|
|
5552
5594
|
throw new Error('Invalid argument given for `wrapper`');
|
|
5553
5595
|
}
|
|
5554
5596
|
|
|
5597
|
+
this.initializeTranslations(options);
|
|
5598
|
+
this.setDefaultOptions();
|
|
5555
5599
|
this.buildOptions(options);
|
|
5556
5600
|
this.prepare();
|
|
5557
5601
|
this.initializeComponents();
|
|
@@ -5562,23 +5606,36 @@ class DataTable {
|
|
|
5562
5606
|
}
|
|
5563
5607
|
}
|
|
5564
5608
|
|
|
5609
|
+
initializeTranslations(options) {
|
|
5610
|
+
this.language = options.language || 'en';
|
|
5611
|
+
this.translationManager = new TranslationManager(this.language);
|
|
5612
|
+
|
|
5613
|
+
if (options.translations) {
|
|
5614
|
+
this.translationManager.addTranslations(options.translations);
|
|
5615
|
+
}
|
|
5616
|
+
}
|
|
5617
|
+
|
|
5618
|
+
setDefaultOptions() {
|
|
5619
|
+
this.DEFAULT_OPTIONS = getDefaultOptions(this);
|
|
5620
|
+
}
|
|
5621
|
+
|
|
5565
5622
|
buildOptions(options) {
|
|
5566
5623
|
this.options = this.options || {};
|
|
5567
5624
|
|
|
5568
5625
|
this.options = Object.assign(
|
|
5569
|
-
{}, DEFAULT_OPTIONS,
|
|
5626
|
+
{}, this.DEFAULT_OPTIONS,
|
|
5570
5627
|
this.options || {}, options
|
|
5571
5628
|
);
|
|
5572
5629
|
|
|
5573
5630
|
options.headerDropdown = options.headerDropdown || [];
|
|
5574
5631
|
this.options.headerDropdown = [
|
|
5575
|
-
...DEFAULT_OPTIONS.headerDropdown,
|
|
5632
|
+
...this.DEFAULT_OPTIONS.headerDropdown,
|
|
5576
5633
|
...options.headerDropdown
|
|
5577
5634
|
];
|
|
5578
5635
|
|
|
5579
5636
|
// custom user events
|
|
5580
5637
|
this.events = Object.assign(
|
|
5581
|
-
{}, DEFAULT_OPTIONS.events,
|
|
5638
|
+
{}, this.DEFAULT_OPTIONS.events,
|
|
5582
5639
|
this.options.events || {},
|
|
5583
5640
|
options.events || {}
|
|
5584
5641
|
);
|
|
@@ -5764,6 +5821,10 @@ class DataTable {
|
|
|
5764
5821
|
console.log.apply(console, arguments);
|
|
5765
5822
|
}
|
|
5766
5823
|
}
|
|
5824
|
+
|
|
5825
|
+
translate(str, args) {
|
|
5826
|
+
return this.translationManager.translate(str, args);
|
|
5827
|
+
}
|
|
5767
5828
|
}
|
|
5768
5829
|
|
|
5769
5830
|
DataTable.instances = 0;
|
|
@@ -5774,15 +5835,15 @@ var description = "A modern datatable library for the web";
|
|
|
5774
5835
|
var main = "dist/melondtable.cjs.js";
|
|
5775
5836
|
var unpkg = "dist/melondtable.min.js";
|
|
5776
5837
|
var jsdelivr = "dist/melondtable.min.js";
|
|
5777
|
-
var scripts = {"start":"yarn run dev","build":"rollup -c && NODE_ENV=production rollup -c","dev":"rollup -c -w","cy:server":"http-server -p 8989","cy:open":"cypress open","cy:run":"cypress run","test":"start-server-and-test cy:server http://localhost:8989 cy:run","test-local":"start-server-and-test cy:server http://localhost:8989 cy:open","travis-deploy-once":"travis-deploy-once","semantic-release":"semantic-release","lint":"eslint src","commit":"npx git-cz"};
|
|
5838
|
+
var scripts = {"start":"yarn run dev","build":"rollup -c && NODE_ENV=production rollup -c","dev":"rollup -c -w","cy:server":"http-server -p 8989","cy:open":"cypress open","cy:run":"cypress run","test":"start-server-and-test cy:server http://localhost:8989 cy:run","test-local":"start-server-and-test cy:server http://localhost:8989 cy:open","travis-deploy-once":"travis-deploy-once","semantic-release":"semantic-release","lint":"eslint src","lint-and-build":"yarn lint && yarn build","commit":"npx git-cz"};
|
|
5778
5839
|
var files = ["dist","src"];
|
|
5779
|
-
var devDependencies = {"autoprefixer":"^9.0.0","chai":"3.5.0","cypress":"
|
|
5840
|
+
var devDependencies = {"autoprefixer":"^9.0.0","chai":"3.5.0","cypress":"^9.2.0","cz-conventional-changelog":"^2.1.0","deepmerge":"^2.0.1","eslint":"^5.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","http-server":"^0.11.1","mocha":"3.3.0","postcss-custom-properties":"^7.0.0","postcss-nested":"^3.0.0","rollup":"^0.59.4","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-eslint":"^4.0.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify-es":"^0.0.1","semantic-release":"^17.1.1","start-server-and-test":"^1.4.1","travis-deploy-once":"^5.0.1"};
|
|
5780
5841
|
var repository = {"type":"git","url":"https://github.com/amonak/melondtable.git"};
|
|
5781
5842
|
var keywords = ["datatable","data","grid","table"];
|
|
5782
5843
|
var author = "Faris Ansari";
|
|
5783
5844
|
var license = "MIT";
|
|
5784
5845
|
var bugs = {"url":"https://github.com/amonak/datatable/issues"};
|
|
5785
|
-
var homepage = "https://
|
|
5846
|
+
var homepage = "https://devel.monakerp.com/datatable";
|
|
5786
5847
|
var dependencies = {"hyperlist":"^1.0.0-beta","lodash":"^4.17.5","sortablejs":"^1.7.0"};
|
|
5787
5848
|
var config = {"commitizen":{"path":"cz-conventional-changelog"}};
|
|
5788
5849
|
var packageJson = {
|