adore-datatable 2.0.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.
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Aufsteigend sortieren",
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} Zelle kopiert",
9
+ "default": "{count} Zellen kopiert"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} Zeile ausgewählt",
13
+ "default": "{count} Zeilen ausgewählt"
14
+ }
15
+ }
@@ -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,13 @@
1
+ import en from './en.json';
2
+ import de from './de.json';
3
+ import fr from './fr.json';
4
+ import it from './it.json';
5
+
6
+ export default function getTranslations() {
7
+ return {
8
+ en,
9
+ de,
10
+ fr,
11
+ it,
12
+ };
13
+ };
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Ordinamento ascendente",
3
+ "Sort Descending": "Ordinamento decrescente",
4
+ "Reset sorting": "Azzeramento ordinamento",
5
+ "Remove column": "Rimuovi colonna",
6
+ "No Data": "Nessun dato",
7
+ "{count} cells copied": {
8
+ "1": "Copiato {count} cella",
9
+ "default": "{count} celle copiate"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} linea selezionata",
13
+ "default": "{count} linee selezionate"
14
+ }
15
+ }
package/src/utils.js ADDED
@@ -0,0 +1,167 @@
1
+ import _throttle from 'lodash/throttle';
2
+ import _debounce from 'lodash/debounce';
3
+ import _uniq from 'lodash/uniq';
4
+
5
+ export function camelCaseToDash(str) {
6
+ return str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`);
7
+ }
8
+
9
+ export function makeDataAttributeString(props) {
10
+ const keys = Object.keys(props);
11
+
12
+ return keys
13
+ .map((key) => {
14
+ const _key = camelCaseToDash(key);
15
+ const val = props[key];
16
+
17
+ if (val === undefined) return '';
18
+ return `data-${_key}="${val}" `;
19
+ })
20
+ .join('')
21
+ .trim();
22
+ }
23
+
24
+ export function copyTextToClipboard(text) {
25
+ // https://stackoverflow.com/a/30810322/5353542
26
+ var textArea = document.createElement('textarea');
27
+
28
+ //
29
+ // *** This styling is an extra step which is likely not required. ***
30
+ //
31
+ // Why is it here? To ensure:
32
+ // 1. the element is able to have focus and selection.
33
+ // 2. if element was to flash render it has minimal visual impact.
34
+ // 3. less flakyness with selection and copying which **might** occur if
35
+ // the textarea element is not visible.
36
+ //
37
+ // The likelihood is the element won't even render, not even a flash,
38
+ // so some of these are just precautions. However in IE the element
39
+ // is visible whilst the popup box asking the user for permission for
40
+ // the web page to copy to the clipboard.
41
+ //
42
+
43
+ // Place in top-left corner of screen regardless of scroll position.
44
+ textArea.style.position = 'fixed';
45
+ textArea.style.top = 0;
46
+ textArea.style.left = 0;
47
+
48
+ // Ensure it has a small width and height. Setting to 1px / 1em
49
+ // doesn't work as this gives a negative w/h on some browsers.
50
+ textArea.style.width = '2em';
51
+ textArea.style.height = '2em';
52
+
53
+ // We don't need padding, reducing the size if it does flash render.
54
+ textArea.style.padding = 0;
55
+
56
+ // Clean up any borders.
57
+ textArea.style.border = 'none';
58
+ textArea.style.outline = 'none';
59
+ textArea.style.boxShadow = 'none';
60
+
61
+ // Avoid flash of white box if rendered for any reason.
62
+ textArea.style.background = 'transparent';
63
+
64
+ textArea.value = text;
65
+
66
+ document.body.appendChild(textArea);
67
+
68
+ textArea.select();
69
+
70
+ try {
71
+ document.execCommand('copy');
72
+ } catch (err) {
73
+ console.log('Oops, unable to copy');
74
+ }
75
+
76
+ document.body.removeChild(textArea);
77
+ }
78
+
79
+ export function isNumeric(val) {
80
+ return !isNaN(val);
81
+ }
82
+
83
+ export let throttle = _throttle;
84
+
85
+ export let debounce = _debounce;
86
+
87
+ export function nextTick(fn, context = null) {
88
+ return (...args) => {
89
+ return new Promise(resolve => {
90
+ const execute = () => {
91
+ const out = fn.apply(context, args);
92
+ resolve(out);
93
+ };
94
+ setTimeout(execute);
95
+ });
96
+ };
97
+ };
98
+
99
+ export function linkProperties(target, source, properties) {
100
+ const props = properties.reduce((acc, prop) => {
101
+ acc[prop] = {
102
+ get() {
103
+ return source[prop];
104
+ }
105
+ };
106
+ return acc;
107
+ }, {});
108
+ Object.defineProperties(target, props);
109
+ };
110
+
111
+ export function isSet(val) {
112
+ return val !== undefined || val !== null;
113
+ }
114
+
115
+ export function notSet(val) {
116
+ return !isSet(val);
117
+ }
118
+
119
+ export function isNumber(val) {
120
+ return !isNaN(val);
121
+ }
122
+
123
+ export function ensureArray(val) {
124
+ if (!Array.isArray(val)) {
125
+ return [val];
126
+ }
127
+ return val;
128
+ }
129
+
130
+ export function uniq(arr) {
131
+ return _uniq(arr);
132
+ }
133
+
134
+ export function numberSortAsc(a, b) {
135
+ return a - b;
136
+ };
137
+
138
+ export function stripHTML(html) {
139
+ return html.replace(/<[^>]*>/g, '');
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
+ };
152
+
153
+ export function escapeHTML(txt) {
154
+ if (!txt) return '';
155
+ let escapeHtmlMapping = {
156
+ '&': '&amp;',
157
+ '<': '&lt;',
158
+ '>': '&gt;',
159
+ '"': '&quot;',
160
+ "'": '&#39;',
161
+ '/': '&#x2F;',
162
+ '`': '&#x60;',
163
+ '=': '&#x3D;',
164
+ };
165
+
166
+ return String(txt).replace(/[&<>"'`=/]/g, (char) => escapeHtmlMapping[char] || char);
167
+ };