@dataloop-ai/components 0.19.34 → 0.19.36
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
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
:color="hasValue ? 'dl-color-secondary' : 'dl-color-medium'"
|
|
9
9
|
variant="h1"
|
|
10
10
|
:size="counterFontSizeComputed"
|
|
11
|
+
:style="counter.unit && { 'text-transform': 'none' }"
|
|
11
12
|
>
|
|
12
13
|
{{ formatCounter(counter) }}
|
|
13
14
|
</dl-typography>
|
|
@@ -61,7 +62,11 @@ import {
|
|
|
61
62
|
DlKpiProgressType
|
|
62
63
|
} from './types/KpiItem'
|
|
63
64
|
import { DlProgressBar, DlTypography } from '../../essential'
|
|
64
|
-
import {
|
|
65
|
+
import {
|
|
66
|
+
abbreviateBytes,
|
|
67
|
+
abbreviateNumber,
|
|
68
|
+
numberWithComma
|
|
69
|
+
} from '../../../utils/formatNumber'
|
|
65
70
|
import KpiInfo from './components/KpiInfo.vue'
|
|
66
71
|
|
|
67
72
|
export default defineComponent({
|
|
@@ -177,7 +182,11 @@ export default defineComponent({
|
|
|
177
182
|
return emptyString
|
|
178
183
|
}
|
|
179
184
|
if (typeof counter.value === 'number') {
|
|
180
|
-
return formatNumberCounter(
|
|
185
|
+
return formatNumberCounter(
|
|
186
|
+
counter.value,
|
|
187
|
+
counter.format,
|
|
188
|
+
counter.unit
|
|
189
|
+
)
|
|
181
190
|
}
|
|
182
191
|
if (typeof counter.value === 'string') {
|
|
183
192
|
if (!counter.value.length) {
|
|
@@ -212,13 +221,22 @@ export default defineComponent({
|
|
|
212
221
|
}
|
|
213
222
|
}
|
|
214
223
|
|
|
215
|
-
const formatNumberCounter = (
|
|
224
|
+
const formatNumberCounter = (
|
|
225
|
+
amount: number,
|
|
226
|
+
format = '',
|
|
227
|
+
unit = ''
|
|
228
|
+
) => {
|
|
216
229
|
if (isNaN(amount)) {
|
|
217
230
|
return emptyString
|
|
218
231
|
}
|
|
219
232
|
if (amount === 0) {
|
|
220
233
|
return 0
|
|
221
234
|
}
|
|
235
|
+
if (unit === 'bytes') {
|
|
236
|
+
return (
|
|
237
|
+
abbreviateBytes(amount as number) as string
|
|
238
|
+
).toUpperCase()
|
|
239
|
+
}
|
|
222
240
|
return format === 'short'
|
|
223
241
|
? (abbreviateNumber(amount as number) as string).toLowerCase()
|
|
224
242
|
: numberWithComma(amount as number)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
class="dl-tabs-wrapper"
|
|
4
|
-
:class="{ 'full-width': fullWidth }"
|
|
4
|
+
:class="{ 'full-width': fullWidth || fluid }"
|
|
5
5
|
:style="cssVars"
|
|
6
6
|
>
|
|
7
7
|
<tabs-wrapper
|
|
@@ -66,6 +66,7 @@ export default defineComponent({
|
|
|
66
66
|
items: { type: Array as PropType<DlTabDetails[]>, required: true },
|
|
67
67
|
vertical: { type: Boolean, default: false },
|
|
68
68
|
fullWidth: { type: Boolean, default: false },
|
|
69
|
+
fluid: { type: Boolean, default: false },
|
|
69
70
|
disabled: { type: Boolean, default: false },
|
|
70
71
|
modelValue: { type: String, required: true },
|
|
71
72
|
fontSize: { type: String, default: '18px' },
|
package/src/demos/DlKpiDemo.vue
CHANGED
|
@@ -85,6 +85,14 @@ import { DlKpi } from '../components'
|
|
|
85
85
|
import { DlKpiCounterFormat, DlKpiItem } from '../components/types'
|
|
86
86
|
|
|
87
87
|
const kpiData: DlKpiItem[] = [
|
|
88
|
+
{
|
|
89
|
+
counter: {
|
|
90
|
+
value: 123456,
|
|
91
|
+
unit: 'bytes'
|
|
92
|
+
},
|
|
93
|
+
title: 'Bytes KiloBytes MegaBytes GigaBytes TeraBytes PetaBytes We have all the bytes',
|
|
94
|
+
infoMessage: 'info message'
|
|
95
|
+
},
|
|
88
96
|
{
|
|
89
97
|
counter: {
|
|
90
98
|
value: 200000000,
|
package/src/demos/DlTabsDemo.vue
CHANGED
|
@@ -13,3 +13,13 @@ export function abbreviateNumber(nr: number) {
|
|
|
13
13
|
compactDisplay: 'short'
|
|
14
14
|
}).format(nr)
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
export function abbreviateBytes(nr: number) {
|
|
18
|
+
if (!nr) return '0B'
|
|
19
|
+
return new Intl.NumberFormat('en-US', {
|
|
20
|
+
notation: 'compact',
|
|
21
|
+
style: 'unit',
|
|
22
|
+
unit: 'byte',
|
|
23
|
+
unitDisplay: 'narrow'
|
|
24
|
+
}).format(nr)
|
|
25
|
+
}
|