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/src/defaults.js CHANGED
@@ -1,71 +1,73 @@
1
1
  import filterRows from './filterRows';
2
2
  import icons from './icons';
3
3
 
4
- export default {
5
- columns: [],
6
- data: [],
7
- dropdownButton: icons.chevronDown,
8
- headerDropdown: [
9
- {
10
- label: 'Sort Ascending',
11
- action: function (column) {
12
- this.sortColumn(column.colIndex, 'asc');
4
+ export default function getDefaultOptions(instance) {
5
+ return {
6
+ columns: [],
7
+ data: [],
8
+ dropdownButton: icons.chevronDown,
9
+ headerDropdown: [
10
+ {
11
+ label: instance.translate('Sort Ascending'),
12
+ action: function (column) {
13
+ this.sortColumn(column.colIndex, 'asc');
14
+ }
15
+ },
16
+ {
17
+ label: instance.translate('Sort Descending'),
18
+ action: function (column) {
19
+ this.sortColumn(column.colIndex, 'desc');
20
+ }
21
+ },
22
+ {
23
+ label: instance.translate('Reset sorting'),
24
+ action: function (column) {
25
+ this.sortColumn(column.colIndex, 'none');
26
+ }
27
+ },
28
+ {
29
+ label: instance.translate('Remove column'),
30
+ action: function (column) {
31
+ this.removeColumn(column.colIndex);
32
+ }
13
33
  }
34
+ ],
35
+ events: {
36
+ onRemoveColumn(column) {},
37
+ onSwitchColumn(column1, column2) {},
38
+ onSortColumn(column) {},
39
+ onCheckRow(row) {},
40
+ onDestroy() {}
14
41
  },
15
- {
16
- label: 'Sort Descending',
17
- action: function (column) {
18
- this.sortColumn(column.colIndex, 'desc');
19
- }
42
+ hooks: {
43
+ columnTotal: null
20
44
  },
21
- {
22
- label: 'Reset sorting',
23
- action: function (column) {
24
- this.sortColumn(column.colIndex, 'none');
25
- }
45
+ sortIndicator: {
46
+ asc: '↑',
47
+ desc: '↓',
48
+ none: ''
26
49
  },
27
- {
28
- label: 'Remove column',
29
- action: function (column) {
30
- this.removeColumn(column.colIndex);
31
- }
32
- }
33
- ],
34
- events: {
35
- onRemoveColumn(column) {},
36
- onSwitchColumn(column1, column2) {},
37
- onSortColumn(column) {},
38
- onCheckRow(row) {},
39
- onDestroy() {}
40
- },
41
- hooks: {
42
- columnTotal: null
43
- },
44
- sortIndicator: {
45
- asc: '↑',
46
- desc: '↓',
47
- none: ''
48
- },
49
- overrideComponents: {
50
- // ColumnManager: CustomColumnManager
51
- },
52
- filterRows: filterRows,
53
- freezeMessage: '',
54
- getEditor: null,
55
- serialNoColumn: true,
56
- checkboxColumn: false,
57
- clusterize: true,
58
- logs: false,
59
- layout: 'fixed', // fixed, fluid, ratio
60
- noDataMessage: 'No Data',
61
- cellHeight: 40,
62
- minimumColumnWidth: 30,
63
- inlineFilters: false,
64
- treeView: false,
65
- checkedRowStatus: true,
66
- dynamicRowHeight: false,
67
- pasteFromClipboard: false,
68
- showTotalRow: false,
69
- direction: 'ltr',
70
- disableReorderColumn: false
50
+ overrideComponents: {
51
+ // ColumnManager: CustomColumnManager
52
+ },
53
+ filterRows: filterRows,
54
+ freezeMessage: '',
55
+ getEditor: null,
56
+ serialNoColumn: true,
57
+ checkboxColumn: false,
58
+ clusterize: true,
59
+ logs: false,
60
+ layout: 'fixed', // fixed, fluid, ratio
61
+ noDataMessage: instance.translate('No Data'),
62
+ cellHeight: 40,
63
+ minimumColumnWidth: 30,
64
+ inlineFilters: false,
65
+ treeView: false,
66
+ checkedRowStatus: true,
67
+ dynamicRowHeight: false,
68
+ pasteFromClipboard: false,
69
+ showTotalRow: false,
70
+ direction: 'ltr',
71
+ disableReorderColumn: false
72
+ };
71
73
  };
package/src/rowmanager.js CHANGED
@@ -133,7 +133,10 @@ export default class RowManager {
133
133
  const checkedRows = this.getCheckedRows();
134
134
  const count = checkedRows.length;
135
135
  if (count > 0) {
136
- this.bodyRenderer.showToastMessage(`${count} row${count > 1 ? 's' : ''} selected`);
136
+ let message = this.instance.translate('{count} rows selected', {
137
+ count: count
138
+ });
139
+ this.bodyRenderer.showToastMessage(message);
137
140
  } else {
138
141
  this.bodyRenderer.clearToastMessage();
139
142
  }
@@ -325,7 +328,8 @@ export default class RowManager {
325
328
  if (props.isFilter) {
326
329
  row = row.map(cell => (Object.assign({}, cell, {
327
330
  content: this.getFilterInput({
328
- colIndex: cell.colIndex
331
+ colIndex: cell.colIndex,
332
+ name: cell.name
329
333
  }),
330
334
  isFilter: 1,
331
335
  isHeader: undefined,
@@ -347,8 +351,10 @@ export default class RowManager {
347
351
  }
348
352
 
349
353
  getFilterInput(props) {
354
+ let title = `title="Filter based on ${props.name || 'Index'}"`;
350
355
  const dataAttr = makeDataAttributeString(props);
351
- return `<input class="dt-filter dt-input" type="text" ${dataAttr} tabindex="1" />`;
356
+ return `<input class="dt-filter dt-input" type="text" ${dataAttr} tabindex="1"
357
+ ${props.colIndex === 0 ? 'disabled' : title} />`;
352
358
  }
353
359
 
354
360
  selector(rowIndex) {
package/src/style.css CHANGED
@@ -164,6 +164,11 @@
164
164
  }
165
165
  }
166
166
 
167
+ .datatable[dir=rtl] .dt-cell__resize-handle {
168
+ right: unset;
169
+ left: -3px;
170
+ }
171
+
167
172
  .icon-open, .icon-close {
168
173
  width: 16px;
169
174
  height: 16px;
package/src/style.js CHANGED
@@ -192,11 +192,6 @@ export default class Style {
192
192
 
193
193
  let naturalWidth = $.style($('.dt-cell__content', $cell), 'width');
194
194
 
195
- if (column.id === '_rowIndex') {
196
- naturalWidth = this.getRowIndexColumnWidth();
197
- column.width = naturalWidth;
198
- }
199
-
200
195
  if (typeof naturalWidth === 'number' && naturalWidth >= column.naturalWidth) {
201
196
  column.naturalWidth = naturalWidth;
202
197
  } else {
@@ -245,6 +240,9 @@ export default class Style {
245
240
  if (!column.width) {
246
241
  column.width = column.naturalWidth;
247
242
  }
243
+ if (column.id === '_rowIndex') {
244
+ column.width = this.getRowIndexColumnWidth();
245
+ }
248
246
  if (column.width < this.options.minimumColumnWidth) {
249
247
  column.width = this.options.minimumColumnWidth;
250
248
  }
@@ -0,0 +1,30 @@
1
+ import { format } from './utils';
2
+ import getTranslations from './translations';
3
+
4
+ export default class TranslationManager {
5
+ constructor(language) {
6
+ this.language = language;
7
+ this.translations = getTranslations();
8
+ }
9
+
10
+ addTranslations(translations) {
11
+ this.translations = Object.assign(this.translations, translations);
12
+ }
13
+
14
+ translate(sourceText, args) {
15
+ let translation = (this.translations[this.language] &&
16
+ this.translations[this.language][sourceText]) || sourceText;
17
+
18
+ if (typeof translation === 'object') {
19
+ translation = args && args.count ?
20
+ this.getPluralizedTranslation(translation, args.count) :
21
+ sourceText;
22
+ }
23
+
24
+ return format(translation, args || {});
25
+ }
26
+
27
+ getPluralizedTranslation(translations, count) {
28
+ return translations[count] || translations['default'];
29
+ }
30
+ };
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Sort Ascending",
3
+ "Sort Descending": "Sort Descending",
4
+ "Reset sorting": "Reset sorting",
5
+ "Remove column": "Remove column",
6
+ "No Data": "No Data",
7
+ "{count} cells copied": {
8
+ "1": "{count} cell copied",
9
+ "default": "{count} cells copied"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} row selected",
13
+ "default": "{count} rows selected"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Trier par ordre croissant",
3
+ "Sort Descending": "Trier par ordre décroissant",
4
+ "Reset sorting": "Réinitialiser le tri",
5
+ "Remove column": "Supprimer colonne",
6
+ "No Data": "Pas de données",
7
+ "{count} cells copied": {
8
+ "1": "{count} cellule copiée",
9
+ "default": "{count} cellules copiées"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} ligne sélectionnée",
13
+ "default": "{count} lignes sélectionnées"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ import en from './en.json';
2
+ import fr from './fr.json';
3
+ import pt from './pt.json';
4
+ import sw from './sw.json';
5
+ import tr from './tr.json';
6
+
7
+ export default function getTranslations() {
8
+ return {
9
+ en,
10
+ fr,
11
+ pt,
12
+ sw,
13
+ tr,
14
+ };
15
+ };
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Ordernar ascendente",
3
+ "Sort Descending": "Ordenar Descendente",
4
+ "Reset sorting": "Redefinir classificação",
5
+ "Remove column": "Remover coluna",
6
+ "No Data": "Sem dados",
7
+ "{count} cells copied": {
8
+ "1": "{count} célula copiada",
9
+ "default": "{count} células copiadas"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} linha selecionada",
13
+ "default": "{count} linhas selecionadas"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Panga Kupanda",
3
+ "Sort Descending": "Panga Kushuka",
4
+ "Reset sorting": "Weka upya kupanga",
5
+ "Remove column": "Ondoa safu wima",
6
+ "No Data": "Hakuna Data",
7
+ "{count} cells copied": {
8
+ "1": "{count} kiini kilichonakiliwa",
9
+ "default": "{count} seli zimenakiliwa"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} safu iliyochaguliwa",
13
+ "default": "{count} safu zilizochaguliwa"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Artan Sıralama",
3
+ "Sort Descending": "Absteigend sortieren",
4
+ "Reset sorting": "Sortierung zurücksetzen",
5
+ "Remove column": "Spalte entfernen",
6
+ "No Data": "Keine Daten",
7
+ "{count} cells copied": {
8
+ "1": "{count} kopyalanan hücre",
9
+ "default": "{count} hücreler kopyalandı"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} satır seçildi",
13
+ "default": "{count} seçilen satırlar"
14
+ }
15
+ }
package/src/utils.js CHANGED
@@ -138,3 +138,14 @@ export function numberSortAsc(a, b) {
138
138
  export function stripHTML(html) {
139
139
  return html.replace(/<[^>]*>/g, '');
140
140
  };
141
+
142
+ export function format(str, args) {
143
+ if (!str) return str;
144
+
145
+ Object.keys(args).forEach(arg => {
146
+ let regex = new RegExp(`{(${arg})}`, 'g');
147
+ str = str.replace(regex, args[arg]);
148
+ });
149
+
150
+ return str;
151
+ };