@politicalwatch/tipi-uikit 1.9.32 → 1.9.34
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@politicalwatch/tipi-uikit",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.34",
|
|
4
4
|
"main": "src/components/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"pluralize": "^8.0.0",
|
|
22
22
|
"qs": "^6.11.2",
|
|
23
23
|
"save-svg-as-png": "^1.4.17",
|
|
24
|
-
"stylelint-config-standard": "^
|
|
24
|
+
"stylelint-config-standard": "^38.0.0",
|
|
25
25
|
"vite-svg-loader": "^5.1.0",
|
|
26
26
|
"vue": "^3.4.0",
|
|
27
27
|
"vue-inline-svg": "^4.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"stylelint": "^16.1.0",
|
|
52
52
|
"terser": "^5.14.2",
|
|
53
53
|
"vite": "^6.0.0",
|
|
54
|
-
"vitest": "^
|
|
54
|
+
"vitest": "^3.0.0"
|
|
55
55
|
},
|
|
56
56
|
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
|
|
57
57
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { to_duration } from '../../../utils';
|
|
1
2
|
import d3chart from '../d3.chart';
|
|
2
3
|
import { select, selectAll } from 'd3-selection';
|
|
3
4
|
import { scaleLinear, scaleOrdinal, scaleSqrt } from 'd3-scale';
|
|
@@ -237,47 +238,6 @@ class d3sunburst extends d3chart {
|
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
240
|
|
|
240
|
-
/**
|
|
241
|
-
* Format durations
|
|
242
|
-
*/
|
|
243
|
-
to_duration(duration) {
|
|
244
|
-
if (duration > 60 * 60 * 1000) {
|
|
245
|
-
return this.to_hour_duration(duration);
|
|
246
|
-
} else if (duration > 60 * 1000) {
|
|
247
|
-
return this.to_min_duration(duration);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return this.to_secs_duration(duration);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
to_secs_duration(duration) {
|
|
254
|
-
const total_secs = duration / 1000;
|
|
255
|
-
const secs = total_secs % 60;
|
|
256
|
-
|
|
257
|
-
return `${Math.floor(secs)} segundos`;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
to_min_duration(duration) {
|
|
261
|
-
const total_secs = duration / 1000;
|
|
262
|
-
const minutes = total_secs / 60;
|
|
263
|
-
const secs = total_secs % 60;
|
|
264
|
-
|
|
265
|
-
return `${Math.floor(minutes)}:${('' + Math.floor(secs)).padStart(2, 0)} min`;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
to_hour_duration(duration) {
|
|
269
|
-
const total_secs = duration / 1000;
|
|
270
|
-
const total_minutes = total_secs / 60;
|
|
271
|
-
const hours = total_minutes / 60;
|
|
272
|
-
const minutes = total_minutes % 60;
|
|
273
|
-
const secs = total_secs % 60;
|
|
274
|
-
|
|
275
|
-
return `${('' + Math.floor(hours)).padStart(2, 0)}:${('' + Math.floor(minutes)).padStart(
|
|
276
|
-
2,
|
|
277
|
-
0
|
|
278
|
-
)}:${('' + Math.floor(secs)).padStart(2, 0)} horas`;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
241
|
/**
|
|
282
242
|
* Add new chart's elements
|
|
283
243
|
*/
|
|
@@ -301,7 +261,7 @@ class d3sunburst extends d3chart {
|
|
|
301
261
|
? pluralize(this.cfg.tooltip.suffix, d.value)
|
|
302
262
|
: this.cfg.tooltip.suffix;
|
|
303
263
|
const text = this.cfg.tooltip.humanReadable
|
|
304
|
-
? `<div>${d.data[this.cfg.key]}: ${
|
|
264
|
+
? `<div>${d.data[this.cfg.key]}: ${to_duration(d.value)}</div>`
|
|
305
265
|
: this.cfg.tooltip.suffix
|
|
306
266
|
? `<div>${d.data[this.cfg.key]}: ${d.value} ${label}</div>`
|
|
307
267
|
: `<div>${d.data[this.cfg.key]}: ${d.value}</div>`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { to_duration } from '../../../utils';
|
|
1
2
|
import d3chart from '../d3.chart';
|
|
2
3
|
import { select, selectAll } from 'd3-selection';
|
|
3
4
|
import { scaleOrdinal, scaleLinear } from 'd3-scale';
|
|
@@ -137,7 +138,7 @@ class d3wordscloud extends d3chart {
|
|
|
137
138
|
default: '#AAA',
|
|
138
139
|
axis: '#000',
|
|
139
140
|
},
|
|
140
|
-
tooltip: { label: false, suffix: false, suffixPlural: false },
|
|
141
|
+
tooltip: { label: false, suffix: false, suffixPlural: false, humanReadable: false },
|
|
141
142
|
transition: { duration: 500, ease: 'easeLinear' },
|
|
142
143
|
});
|
|
143
144
|
}
|
|
@@ -261,9 +262,12 @@ class d3wordscloud extends d3chart {
|
|
|
261
262
|
const label = this.cfg.tooltip.suffixPlural
|
|
262
263
|
? pluralize(this.cfg.tooltip.suffix, d.value)
|
|
263
264
|
: this.cfg.tooltip.suffix;
|
|
264
|
-
const text = this.cfg.tooltip.
|
|
265
|
-
? `<div>${d.
|
|
266
|
-
:
|
|
265
|
+
const text = this.cfg.tooltip.humanReadable
|
|
266
|
+
? `<div>${to_duration(d.value)}</div>`
|
|
267
|
+
: this.cfg.tooltip.suffix
|
|
268
|
+
? `<div>${d.text}: ${d.value} ${label}</div>`
|
|
269
|
+
: `<div>${d.text}: ${d.value}</div>`;
|
|
270
|
+
|
|
267
271
|
this.tooltip.html(text).classed('active', true);
|
|
268
272
|
})
|
|
269
273
|
.on('mouseout', () => {
|
package/src/utils/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
// case insensitive, digits to number interpolation
|
|
2
2
|
export const naturalSort = function (as, bs) {
|
|
3
|
-
let a,
|
|
4
|
-
|
|
3
|
+
let a,
|
|
4
|
+
b,
|
|
5
|
+
a1,
|
|
6
|
+
b1,
|
|
7
|
+
i = 0,
|
|
8
|
+
L,
|
|
9
|
+
rx = /(\d+)|(\D+)/g,
|
|
5
10
|
rd = /\d/;
|
|
6
11
|
if (isFinite(as) && isFinite(bs)) return as - bs;
|
|
7
12
|
a = String(as).toLowerCase();
|
|
@@ -16,11 +21,52 @@ export const naturalSort = function (as, bs) {
|
|
|
16
21
|
b1 = b[i++];
|
|
17
22
|
if (a1 !== b1) {
|
|
18
23
|
if (isFinite(a1) && isFinite(b1)) {
|
|
19
|
-
if (a1.charAt(0) ===
|
|
20
|
-
if (b1.charAt(0) ===
|
|
24
|
+
if (a1.charAt(0) === '0') a1 = '.' + a1;
|
|
25
|
+
if (b1.charAt(0) === '0') b1 = '.' + b1;
|
|
21
26
|
return a1 - b1;
|
|
22
27
|
} else return a1 > b1 ? 1 : -1;
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
return a.length - b.length;
|
|
26
31
|
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Format durations
|
|
35
|
+
*/
|
|
36
|
+
export const to_duration = function (duration) {
|
|
37
|
+
if (duration > 60 * 60 * 1000) {
|
|
38
|
+
return to_hour_duration(duration);
|
|
39
|
+
} else if (duration > 60 * 1000) {
|
|
40
|
+
return to_min_duration(duration);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return to_secs_duration(duration);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const to_secs_duration = function (duration) {
|
|
47
|
+
const total_secs = duration / 1000;
|
|
48
|
+
const secs = total_secs % 60;
|
|
49
|
+
|
|
50
|
+
return `${Math.floor(secs)} segundos`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const to_min_duration = function (duration) {
|
|
54
|
+
const total_secs = duration / 1000;
|
|
55
|
+
const minutes = total_secs / 60;
|
|
56
|
+
const secs = total_secs % 60;
|
|
57
|
+
|
|
58
|
+
return `${Math.floor(minutes)}:${('' + Math.floor(secs)).padStart(2, 0)} min`;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const to_hour_duration = function (duration) {
|
|
62
|
+
const total_secs = duration / 1000;
|
|
63
|
+
const total_minutes = total_secs / 60;
|
|
64
|
+
const hours = total_minutes / 60;
|
|
65
|
+
const minutes = total_minutes % 60;
|
|
66
|
+
const secs = total_secs % 60;
|
|
67
|
+
|
|
68
|
+
return `${('' + Math.floor(hours)).padStart(2, 0)}:${('' + Math.floor(minutes)).padStart(
|
|
69
|
+
2,
|
|
70
|
+
0
|
|
71
|
+
)}:${('' + Math.floor(secs)).padStart(2, 0)} horas`;
|
|
72
|
+
};
|