@dataloop-ai/components 0.14.6 → 0.15.3

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": "@dataloop-ai/components",
3
- "version": "0.14.6",
3
+ "version": "0.15.3",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -217,9 +217,9 @@ body {
217
217
  --dl-color-lighter: #ffffff66;
218
218
  --dl-color-hover: #AEB9FF;
219
219
  --dl-color-disabled: #ffffff40;
220
- --dl-color-fill: #ffffff40;
221
- --dl-color-fill-secondary: #F8F8F8;
222
- --dl-color-fill-hover: #ffffff26;
220
+ --dl-color-fill: #ffffff0D;
221
+ --dl-color-fill-secondary: #F8F8F81A;
222
+ --dl-color-fill-hover: #ffffff1A;
223
223
  --dl-color-separator: #ffffff26;
224
224
  --dl-color-body-background: #24282D;
225
225
  --dl-color-panel-background: #30363D;
@@ -233,8 +233,8 @@ body {
233
233
  --dl-color-positive-background: #3A644E;
234
234
  --dl-color-info-background: #2F3C4B;
235
235
  --dl-color-icon-default: #ffffffbf;
236
- --dl-color-fill-secondary: #FFFFFF %10;
237
- --dl-color-fill-third: #9E9E9E %10;
236
+ --dl-color-fill-secondary: #FFFFFF1A;
237
+ --dl-color-fill-third: #9E9E9E1A;
238
238
  --dl-color-link: #53B2E8;
239
239
  --dl-color-info: #92CDF2;
240
240
  --dl-color-cell-background: #FFFAE2;
@@ -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) return abbreviateToString(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`]
@@ -78,8 +78,8 @@ export default defineComponent({
78
78
  id: { type: [String, Number], default: null },
79
79
  label: { type: String, default: null },
80
80
  padding: { type: String, default: '5px' },
81
- modelValue: { type: [String, Number], required: true },
82
- value: { type: [String, Number], required: true },
81
+ modelValue: { type: [String, Number, Boolean], required: true },
82
+ value: { type: [String, Number, Boolean], required: true },
83
83
  tabindex: { type: String, default: '0' },
84
84
  subLabel: { type: String, default: '' },
85
85
  subLabelSize: { type: String, default: '10px' }
@@ -1,14 +1,23 @@
1
- export function abbreviateToString(value: number): string {
2
- const suffixes = ['', 'k', 'm', 'b', 't']
3
- const suffixNum = Math.floor(('' + value).length / 3)
4
- const shortValue = parseFloat(
5
- (suffixNum !== 0
6
- ? value / Math.pow(1000, suffixNum)
7
- : value
8
- ).toPrecision(2)
9
- )
10
- if (shortValue % 1 !== 0) {
11
- shortValue.toFixed(1)
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
  }