@dataloop-ai/components 0.15.2 → 0.15.4-table-fix.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.
package/package.json
CHANGED
|
@@ -88,7 +88,10 @@ export default defineComponent({
|
|
|
88
88
|
return value[0].toUpperCase() + value.slice(1)
|
|
89
89
|
},
|
|
90
90
|
abbreviateNumber(nr: number) {
|
|
91
|
-
if (nr
|
|
91
|
+
if (typeof nr === 'number') {
|
|
92
|
+
return abbreviateToString(nr)
|
|
93
|
+
}
|
|
94
|
+
return nr
|
|
92
95
|
},
|
|
93
96
|
computeClass(value: string): (string | boolean)[] {
|
|
94
97
|
return [value, this.small && `${value}--small`]
|
|
@@ -620,12 +620,7 @@ export default defineComponent({
|
|
|
620
620
|
const virtScrollRef = ref(null)
|
|
621
621
|
const hasVirtScroll = computed(() => props.virtualScroll === true)
|
|
622
622
|
|
|
623
|
-
const {
|
|
624
|
-
hasClickEvent,
|
|
625
|
-
hasDblClickEvent,
|
|
626
|
-
hasContextMenuEvent,
|
|
627
|
-
hasAnyAction
|
|
628
|
-
} = useTableActions(props)
|
|
623
|
+
const { hasAnyAction } = useTableActions(props) // todo: does not work
|
|
629
624
|
|
|
630
625
|
const getRowKey = computed(() =>
|
|
631
626
|
typeof props.rowKey === 'function'
|
|
@@ -1110,9 +1105,7 @@ export default defineComponent({
|
|
|
1110
1105
|
row: TableRow,
|
|
1111
1106
|
pageIndex: number
|
|
1112
1107
|
) => {
|
|
1113
|
-
|
|
1114
|
-
emit('row-click', evt, row, pageIndex)
|
|
1115
|
-
}
|
|
1108
|
+
emit('row-click', evt, row, pageIndex)
|
|
1116
1109
|
}
|
|
1117
1110
|
|
|
1118
1111
|
const onTrDblClick = (
|
|
@@ -1120,9 +1113,7 @@ export default defineComponent({
|
|
|
1120
1113
|
row: TableRow,
|
|
1121
1114
|
pageIndex: number
|
|
1122
1115
|
) => {
|
|
1123
|
-
|
|
1124
|
-
emit('row-dblclick', evt, row, pageIndex)
|
|
1125
|
-
}
|
|
1116
|
+
emit('row-dblclick', evt, row, pageIndex)
|
|
1126
1117
|
}
|
|
1127
1118
|
|
|
1128
1119
|
const onTrContextMenu = (
|
|
@@ -1130,9 +1121,7 @@ export default defineComponent({
|
|
|
1130
1121
|
row: TableRow,
|
|
1131
1122
|
pageIndex: number
|
|
1132
1123
|
) => {
|
|
1133
|
-
|
|
1134
|
-
emit('row-contextmenu', evt, row, pageIndex)
|
|
1135
|
-
}
|
|
1124
|
+
emit('row-contextmenu', evt, row, pageIndex)
|
|
1136
1125
|
}
|
|
1137
1126
|
|
|
1138
1127
|
function injectBodyCommonScope(data: Record<string, any>) {
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
export function abbreviateToString(
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
10
|
-
if (
|
|
11
|
-
|
|
1
|
+
export function abbreviateToString(num: number, precision: number = 1): string {
|
|
2
|
+
const abbreviations = [
|
|
3
|
+
{ value: 1e12, suffix: 'T' },
|
|
4
|
+
{ value: 1e9, suffix: 'B' },
|
|
5
|
+
{ value: 1e6, suffix: 'M' },
|
|
6
|
+
{ value: 1e3, suffix: 'K' }
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
const match = abbreviations.find((abb) => num >= abb.value)
|
|
10
|
+
if (!match) {
|
|
11
|
+
return num.toString()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const abbreviated = (num / match.value).toFixed(precision)
|
|
15
|
+
const formatted = Number(abbreviated).toString()
|
|
16
|
+
const suffix = match.suffix
|
|
17
|
+
|
|
18
|
+
if (formatted.includes('.')) {
|
|
19
|
+
return formatted.replace(/\.?0*$/, '') + suffix
|
|
20
|
+
} else {
|
|
21
|
+
return formatted + suffix
|
|
12
22
|
}
|
|
13
|
-
return shortValue + suffixes[suffixNum]
|
|
14
23
|
}
|